CVS commit by ossi: create more descriptive account names, so password prompts look sane. the channel names follow the old scheme, though - they are used to compose sync state file names, and i don't feel like writing a migrator for this.
M +39 -14 config.c 1.6 M +2 -0 isync.h 1.5 --- isync/src/compat/config.c #1.5:1.6 @@ -242,14 +242,12 @@ write_imap_server( FILE *fp, config_t *c char *p, *p2; int hl, a1, a2, a3, a4; - char buf[128]; + char buf[128], ubuf[64]; static int tunnels; - if (cfg->tunnel) { - nfasprintf( (char **)&cfg->server_name, "tunnel%d", ++tunnels ); - fprintf( fp, "IMAPAccount %s\nTunnel \"%s\"\n", - cfg->server_name, cfg->tunnel ); - } else { + if (cfg->tunnel) + nfasprintf( (char **)&cfg->old_server_name, "tunnel%d", ++tunnels ); + else { if (sscanf( cfg->host, "%d.%d.%d.%d", &a1, &a2, &a3, &a4 ) == 4) - cfg->server_name = nfstrdup( cfg->host ); + cfg->old_server_name = nfstrdup( cfg->host ); else { p = strrchr( cfg->host, '.' ); @@ -265,12 +263,39 @@ write_imap_server( FILE *fp, config_t *c for (pbox = boxes; pbox != cfg; pbox = pbox->next) if (!memcmp( pbox->server_name, buf, hl + 1 )) { - nfasprintf( (char **)&cfg->server_name, "%s-%d", buf, ++pbox->servers ); + nfasprintf( (char **)&cfg->old_server_name, "%s-%d", buf, ++pbox->old_servers ); goto gotsrv; } - cfg->server_name = nfstrdup( buf ); - cfg->servers = 1; + cfg->old_server_name = nfstrdup( buf ); + cfg->old_servers = 1; gotsrv: ; } + } + + if (cfg->user) + nfsnprintf( ubuf, sizeof(ubuf), "%s@", cfg->user ); + else + ubuf[0] = 0; + if (!cfg->host) + hl = nfsnprintf( buf, sizeof(buf), "%stunnel", ubuf ); + else { + if (cfg->port != (cfg->use_imaps ? 993 : 143)) + hl = nfsnprintf( buf, sizeof(buf), "%s%s_%d", ubuf, cfg->host, cfg->port ); + else + hl = nfsnprintf( buf, sizeof(buf), "%s%s", ubuf, cfg->host ); + } + if (boxes) /* !o2o */ + for (pbox = boxes; pbox != cfg; pbox = pbox->next) + if (!memcmp( pbox->server_name, buf, hl + 1 )) { + nfasprintf( (char **)&cfg->server_name, "%s-%d", buf, ++pbox->servers ); + goto ngotsrv; + } + cfg->server_name = nfstrdup( buf ); + cfg->servers = 1; + ngotsrv: ; + fprintf( fp, "IMAPAccount %s\n", cfg->server_name ); + if (cfg->tunnel) + fprintf( fp, "Tunnel \"%s\"\n", cfg->tunnel ); + else { if (cfg->use_imaps) fprintf( fp, "Host imaps:%s\n", cfg->host ); @@ -297,7 +322,7 @@ write_imap_store( FILE *fp, config_t *cf { if (cfg->stores > 1) - nfasprintf( (char **)&cfg->store_name, "%s-%d", cfg->server_name, cfg->stores ); + nfasprintf( (char **)&cfg->store_name, "%s-%d", cfg->old_server_name, cfg->stores ); else - cfg->store_name = cfg->server_name; + cfg->store_name = cfg->old_server_name; fprintf( fp, "IMAPStore %s\nAccount %s\n", cfg->store_name, cfg->server_name ); --- isync/src/compat/isync.h #1.4:1.5 @@ -42,5 +42,7 @@ typedef struct config { const char *server_name; + const char *old_server_name; int servers; + int old_servers; char *host; int port; _______________________________________________ isync-devel mailing list isync-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/isync-devel