diff options
author | Eduardo Chappa <chappa@washington.edu> | 2020-10-03 13:43:35 -0600 |
---|---|---|
committer | Eduardo Chappa <chappa@washington.edu> | 2020-10-03 13:43:35 -0600 |
commit | 9064dd878d981f06e15278605ba34a299eba375f (patch) | |
tree | e85fe2dc77658427d6a013d6a5b39b1028d987c2 /alpine | |
parent | 2f6e4c8855e3ea23cbbfcb1a91ea10abbda29d85 (diff) | |
download | alpine-9064dd878d981f06e15278605ba34a299eba375f.tar.xz |
* Set up the IMAP ID at the moment of loging in to the server, rather than
as a one time option, in case we need to use a special IMAP ID.
Diffstat (limited to 'alpine')
-rw-r--r-- | alpine/alpine.c | 8 | ||||
-rw-r--r-- | alpine/imap.c | 38 | ||||
-rw-r--r-- | alpine/imap.h | 1 |
3 files changed, 38 insertions, 9 deletions
diff --git a/alpine/alpine.c b/alpine/alpine.c index 5182e86..7c63e77 100644 --- a/alpine/alpine.c +++ b/alpine/alpine.c @@ -160,14 +160,6 @@ main(int argc, char **argv) ----------------------------------------------------------------------*/ pine_state = new_pine_struct(); - pine_state->id = fs_get(sizeof(IDLIST)); - pine_state->id->name = cpystr("name"); - pine_state->id->value = cpystr(PACKAGE_NAME); - pine_state->id->next = fs_get(sizeof(IDLIST)); - pine_state->id->next->name = cpystr("version"); - pine_state->id->next->value = cpystr(PACKAGE_VERSION); - pine_state->id->next->next = NULL; - mail_parameters(NULL, SET_IDPARAMS, (void *) pine_state->id); ps_global = pine_state; /* diff --git a/alpine/imap.c b/alpine/imap.c index f1654de..b4e044e 100644 --- a/alpine/imap.c +++ b/alpine/imap.c @@ -170,6 +170,8 @@ OAUTH2_S alpine_oauth2_list[] = }, {NULL, NULL, NULL, 0, 0, NULL}, /* device_code information */ NULL, /* access token */ + NULL, /* special IMAP ID */ + 0, /* do not hide */ 0, /* expiration time */ 0, /* first time indicator */ 1, /* client secret required */ @@ -200,6 +202,8 @@ OAUTH2_S alpine_oauth2_list[] = }, {NULL, NULL, NULL, 0, 0, NULL}, /* device_code information */ NULL, /* access token */ + NULL, /* special IMAP ID */ + 0, /* do not hide */ 0, /* expiration time */ 0, /* first time indicator */ 0, /* client secret required */ @@ -230,6 +234,8 @@ OAUTH2_S alpine_oauth2_list[] = }, {NULL, NULL, NULL, 0, 0, NULL}, /* device_code information, not used */ NULL, /* access token */ + NULL, /* special IMAP ID */ + 0, /* do not hide */ 0, /* expiration time */ 0, /* first time indicator */ 1, /* client secret required */ @@ -260,12 +266,14 @@ OAUTH2_S alpine_oauth2_list[] = }, {NULL, NULL, NULL, 0, 0, NULL}, /* device_code information, not used */ NULL, /* access token */ + NULL, /* special IMAP ID */ + 0, /* do not hide */ 0, /* expiration time */ 0, /* first time indicator */ 1, /* client secret required */ 0 /* Cancel refresh token */ }, - { NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0}, + { NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0}, }; int @@ -981,6 +989,12 @@ mm_login_oauth2(NETMBX *mb, char *user, char *method, hostlist2[j].next = &hostlist2[j+1]; } + if(registered){ /* redo the app_id, no questions asked */ + free_id(&ps_global->id); + ps_global->id = set_alpine_id(oa2list->app_id ? oa2list->app_id : PACKAGE_NAME, PACKAGE_VERSION); + mail_parameters(NULL, SET_IDPARAMS, (void *) ps_global->id); + } + /* * We check if we have a refresh token saved somewhere, if so * we use it to get a new access token, otherwise we need to @@ -1178,6 +1192,23 @@ mm_login_oauth2(NETMBX *mb, char *user, char *method, ps_global->no_newmail_check_from_optionally_enter = 0; } +IDLIST * +set_alpine_id(unsigned char *pname, unsigned char *pversion) +{ + IDLIST *id; + + if(!pname || !pversion) return NULL; + + id = fs_get(sizeof(IDLIST)); + id->name = cpystr("name"); + id->value = cpystr(pname); + id->next = fs_get(sizeof(IDLIST)); + id->next->name = cpystr("version"); + id->next->value = cpystr(pversion); + id->next->next = NULL; + return id; +} + /*---------------------------------------------------------------------- receive notification from IMAP @@ -1439,6 +1470,11 @@ mm_login_work(NETMBX *mb, char *user, char **pwd, long int trial, if(ps_global->ttyo) flush_status_messages(0); + /* redo app id in case we are loging in to an IMAP server that supports the IMAP ID extension */ + free_id(&ps_global->id); + ps_global->id = set_alpine_id(PACKAGE_NAME, PACKAGE_VERSION); + mail_parameters(NULL, SET_IDPARAMS, (void *) ps_global->id); + /* * Add port number to hostname if going through a tunnel or something */ diff --git a/alpine/imap.h b/alpine/imap.h index e595e19..8bf0291 100644 --- a/alpine/imap.h +++ b/alpine/imap.h @@ -31,6 +31,7 @@ char *pine_newsrcquery(MAILSTREAM *, char *, char *); int url_local_certdetails(char *); void pine_sslfailure(char *, char *, unsigned long); void mm_expunged_current(long unsigned int); +IDLIST *set_alpine_id(unsigned char *, unsigned char *); char *oauth2_get_access_code(unsigned char *, char *, OAUTH2_S *, int *); void oauth2_set_device_info(OAUTH2_S *, char *); int oauth2_elapsed_done(void *); |