summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--alpine/alpine.c8
-rw-r--r--alpine/imap.c38
-rw-r--r--alpine/imap.h1
-rw-r--r--imap/src/c-client/mail.c10
-rw-r--r--imap/src/c-client/mail.h4
-rw-r--r--pith/pine.hlp5
-rw-r--r--pith/state.c3
7 files changed, 58 insertions, 11 deletions
diff --git a/alpine/alpine.c b/alpine/alpine.c
index 5182e869..7c63e77a 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 f1654dec..b4e044e7 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 e595e196..8bf02916 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 *);
diff --git a/imap/src/c-client/mail.c b/imap/src/c-client/mail.c
index b52d0626..981025c1 100644
--- a/imap/src/c-client/mail.c
+++ b/imap/src/c-client/mail.c
@@ -326,6 +326,16 @@ void mail_link (DRIVER *driver)
driver->next = NIL; /* this driver is the end of the list */
}
+void free_id(IDLIST **idp)
+{
+ if(!idp || !*idp) return;
+
+ if((*idp)->name) fs_give((void **) &(*idp)->name);
+ if((*idp)->value) fs_give((void **) &(*idp)->value);
+ if((*idp)->next) free_id (&(*idp)->next);
+ fs_give((void **)idp);
+}
+
/* Mail manipulate driver parameters
* Accepts: mail stream
* function code
diff --git a/imap/src/c-client/mail.h b/imap/src/c-client/mail.h
index 13bbc84f..79f0b3f3 100644
--- a/imap/src/c-client/mail.h
+++ b/imap/src/c-client/mail.h
@@ -1890,7 +1890,7 @@ void auth_link (AUTHENTICATOR *auth);
char *mail_auth (char *mechanism,authresponse_t resp,int argc,char *argv[]);
AUTHENTICATOR *mail_lookup_auth (unsigned long i);
unsigned int mail_lookup_auth_name (char *mechanism,long flags);
-
+void free_id(IDLIST **);
NETSTREAM *net_open (NETMBX *mb,NETDRIVER *dv,unsigned long port,
NETDRIVER *ssld,char *ssls,unsigned long sslp);
NETSTREAM *net_open_work (NETDRIVER *dv,char *host,char *service,
@@ -1986,6 +1986,8 @@ typedef struct oauth2_s {
OAUTH2_SERVER_METHOD_S server_mthd[OA2_GetEnd];
OAUTH2_DEVICECODE_S devicecode;
char *access_token;
+ char *app_id; /* special id for this server */
+ unsigned hide:1; /* hide this from user */
unsigned long expiration;
unsigned int first_time:1; /* this is the first time we get credentials for this account */
unsigned int require_secret:1; /* this server requires a client-secret */
diff --git a/pith/pine.hlp b/pith/pine.hlp
index 746d6201..94a22588 100644
--- a/pith/pine.hlp
+++ b/pith/pine.hlp
@@ -140,7 +140,7 @@ with help text for the config screen and the composer that didn't have any
reasonable place to be called from.
Dummy change to get revision in pine.hlp
============= h_revision =================
-Alpine Commit 507 2020-09-27 09:53:59
+Alpine Commit 508 2020-10-03 13:43:20
============= h_news =================
<HTML>
<HEAD>
@@ -256,6 +256,9 @@ problems you find with this release.
<LI> When a server expires a refresh token, Alpine needs to cancel it
internally. Alpine will attempt to get a new one when it reopens the
folder after it cancels it.
+
+<LI> 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.
</UL>
<P>
diff --git a/pith/state.c b/pith/state.c
index a7728d67..1246f32c 100644
--- a/pith/state.c
+++ b/pith/state.c
@@ -248,6 +248,9 @@ free_pine_struct(struct pine **pps)
if((*pps)->msgmap)
msgno_give(&(*pps)->msgmap);
+
+ if((*pps)->id)
+ free_id(&(*pps)->id);
free_vars(*pps);