aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2014-10-17 23:37:41 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2014-10-17 23:37:41 +0100
commit9ead105e86e6ae332ebdcbc2f1582775b6ef6d38 (patch)
tree9495539922feee5c5e695d445676877ec154281e
parent4f7255d4bed610a77cefd9786fe13c1d673b11bb (diff)
parent46511b3c928bea3072c8c1012b92a3057fa77517 (diff)
Bunch of merges from dx.
-rw-r--r--lib/xmltree.c16
-rw-r--r--lib/xmltree.h1
-rw-r--r--nick.c4
-rw-r--r--protocols/jabber/io.c5
-rw-r--r--protocols/jabber/jabber.c4
-rw-r--r--protocols/jabber/jabber.h4
-rw-r--r--protocols/jabber/jabber_util.c30
-rw-r--r--protocols/jabber/sasl.c21
8 files changed, 49 insertions, 36 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c
index 3d9eb735..6253d760 100644
--- a/lib/xmltree.c
+++ b/lib/xmltree.c
@@ -523,6 +523,22 @@ char *xt_find_attr( struct xt_node *node, const char *key )
return node->attr[i].value;
}
+struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value )
+{
+ struct xt_node *c;
+ char *s;
+
+ for( c = xt; ( c = xt_find_node( c, tag ) ); c = c->next )
+ {
+ if( ( s = xt_find_attr( c, key ) ) && strcmp( s, value ) == 0 )
+ {
+ return c;
+ }
+ }
+ return NULL;
+}
+
+
/* Strip a few non-printable characters that aren't allowed in XML streams
(and upset some XMPP servers for example). */
void xt_strip_text( char *in )
diff --git a/lib/xmltree.h b/lib/xmltree.h
index c1451dad..af13b859 100644
--- a/lib/xmltree.h
+++ b/lib/xmltree.h
@@ -91,6 +91,7 @@ void xt_free( struct xt_parser *xt );
struct xt_node *xt_find_node( struct xt_node *node, const char *name );
struct xt_node *xt_find_path( struct xt_node *node, const char *name );
char *xt_find_attr( struct xt_node *node, const char *key );
+struct xt_node *xt_find_node_by_attr( struct xt_node *xt, const char *tag, const char *key, const char *value );
struct xt_node *xt_new_node( char *name, const char *text, struct xt_node *children );
void xt_add_child( struct xt_node *parent, struct xt_node *child );
diff --git a/nick.c b/nick.c
index dd8b0ddf..f780341f 100644
--- a/nick.c
+++ b/nick.c
@@ -407,8 +407,8 @@ int nick_lc( irc_t *irc, char *nick )
}
for( i = 0; nick[i]; i ++ )
- if( nick[i] < 0x7f )
- nick[i] = tab[(int)nick[i]];
+ if( ((guchar)nick[i]) < 0x7f )
+ nick[i] = tab[(guchar)nick[i]];
return nick_ok( irc, nick );
}
diff --git a/protocols/jabber/io.c b/protocols/jabber/io.c
index 6f79b2d1..a8f7d09f 100644
--- a/protocols/jabber/io.c
+++ b/protocols/jabber/io.c
@@ -505,6 +505,11 @@ static xt_status jabber_pkt_stream_error( struct xt_node *node, gpointer data )
imcb_error( ic, "Account and resource used from a different location" );
allow_reconnect = FALSE;
}
+ else if( strcmp( err->code, "not-authorized" ) == 0 )
+ {
+ imcb_error( ic, "Not authorized" );
+ allow_reconnect = FALSE;
+ }
else
{
imcb_error( ic, "Stream error: %s%s%s", err->code, err->text ? ": " : "",
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index dab4afdf..4b5cb3a1 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -147,9 +147,7 @@ static void jabber_login( account_t *acc )
jd->fd = jd->r_inpa = jd->w_inpa = -1;
- if( strstr( jd->server, ".live.com" ) )
- jd->oauth2_service = &oauth2_service_mslive;
- else if( strstr( jd->server, ".facebook.com" ) )
+ if( strstr( jd->server, ".facebook.com" ) )
jd->oauth2_service = &oauth2_service_facebook;
else
jd->oauth2_service = &oauth2_service_google;
diff --git a/protocols/jabber/jabber.h b/protocols/jabber/jabber.h
index 21769a3b..eb99f9ca 100644
--- a/protocols/jabber/jabber.h
+++ b/protocols/jabber/jabber.h
@@ -228,7 +228,8 @@ struct jabber_transfer
#define XMLNS_PING "urn:xmpp:ping" /* XEP-0199 */
#define XMLNS_RECEIPTS "urn:xmpp:receipts" /* XEP-0184 */
#define XMLNS_VCARD "vcard-temp" /* XEP-0054 */
-#define XMLNS_DELAY "jabber:x:delay" /* XEP-0091 */
+#define XMLNS_DELAY_OLD "jabber:x:delay" /* XEP-0091 */
+#define XMLNS_DELAY "urn:xmpp:delay" /* XEP-0203 */
#define XMLNS_XDATA "jabber:x:data" /* XEP-0004 */
#define XMLNS_CHATSTATES "http://jabber.org/protocol/chatstates" /* XEP-0085 */
#define XMLNS_DISCO_INFO "http://jabber.org/protocol/disco#info" /* XEP-0030 */
@@ -337,7 +338,6 @@ int sasl_oauth2_refresh( struct im_connection *ic, const char *refresh_token );
extern const struct oauth2_service oauth2_service_google;
extern const struct oauth2_service oauth2_service_facebook;
-extern const struct oauth2_service oauth2_service_mslive;
/* conference.c */
struct groupchat *jabber_chat_join( struct im_connection *ic, const char *room, const char *nick, const char *password );
diff --git a/protocols/jabber/jabber_util.c b/protocols/jabber/jabber_util.c
index 0fcc8338..fb68c33d 100644
--- a/protocols/jabber/jabber_util.c
+++ b/protocols/jabber/jabber_util.c
@@ -725,19 +725,29 @@ time_t jabber_get_timestamp( struct xt_node *xt )
struct xt_node *c;
char *s = NULL;
struct tm tp;
-
- for( c = xt->children; ( c = xt_find_node( c, "x" ) ); c = c->next )
- {
- if( ( s = xt_find_attr( c, "xmlns" ) ) && strcmp( s, XMLNS_DELAY ) == 0 )
- break;
+ gboolean is_old = TRUE;
+ const char *format;
+
+ /* XEP-0091 has <x> */
+ c = xt_find_node_by_attr( xt->children, "x", "xmlns", XMLNS_DELAY_OLD );
+
+ if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) {
+ is_old = FALSE;
+
+ /* XEP-0203 has <delay> */
+ c = xt_find_node_by_attr( xt->children, "delay", "xmlns", XMLNS_DELAY );
+ if( !c || !( s = xt_find_attr( c, "stamp" ) ) ) {
+ return 0;
+ }
}
- if( !c || !( s = xt_find_attr( c, "stamp" ) ) )
- return 0;
-
memset( &tp, 0, sizeof( tp ) );
- if( sscanf( s, "%4d%2d%2dT%2d:%2d:%2d", &tp.tm_year, &tp.tm_mon, &tp.tm_mday,
- &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) != 6 )
+
+ /* The other main difference between XEPs is the timestamp format */
+ format = (is_old) ? "%4d%2d%2dT%2d:%2d:%2d" : "%4d-%2d-%2dT%2d:%2d:%2dZ";
+
+ if( sscanf( s, format, &tp.tm_year, &tp.tm_mon, &tp.tm_mday,
+ &tp.tm_hour, &tp.tm_min, &tp.tm_sec ) != 6 )
return 0;
tp.tm_year -= 1900;
diff --git a/protocols/jabber/sasl.c b/protocols/jabber/sasl.c
index 12111fc7..a4d1f6c1 100644
--- a/protocols/jabber/sasl.c
+++ b/protocols/jabber/sasl.c
@@ -46,15 +46,6 @@ const struct oauth2_service oauth2_service_facebook =
"126828914005625",
"4b100f0f244d620bf3f15f8b217d4c32",
};
-const struct oauth2_service oauth2_service_mslive =
-{
- "https://oauth.live.com/authorize",
- "https://oauth.live.com/token",
- "http://www.bitlbee.org/main.php/Messenger/oauth2.html",
- "wl.offline_access%20wl.messenger",
- "000000004C06FCD1",
- "IRKlBPzJJAWcY-TbZjiTEJu9tn7XCFaV",
-};
xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
{
@@ -62,7 +53,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
struct jabber_data *jd = ic->proto_data;
struct xt_node *c, *reply;
char *s;
- int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0, sup_ms = 0;
+ int sup_plain = 0, sup_digest = 0, sup_gtalk = 0, sup_fb = 0;
int want_oauth = FALSE;
GString *mechs;
@@ -97,8 +88,6 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
sup_gtalk = 1;
else if( c->text && g_strcasecmp( c->text, "X-FACEBOOK-PLATFORM" ) == 0 )
sup_fb = 1;
- else if( c->text && g_strcasecmp( c->text, "X-MESSENGER-OAUTH2" ) == 0 )
- sup_ms = 1;
if( c->text )
g_string_append_printf( mechs, " %s", c->text );
@@ -108,7 +97,7 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
if( !want_oauth && !sup_plain && !sup_digest )
{
- if( !sup_gtalk && !sup_fb && !sup_ms )
+ if( !sup_gtalk && !sup_fb )
imcb_error( ic, "This server requires OAuth "
"(supported schemes:%s)", mechs->str );
else
@@ -141,12 +130,6 @@ xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data )
reply->text_len = strlen( reply->text );
g_free( s );
}
- else if( sup_ms && want_oauth )
- {
- xt_add_attr( reply, "mechanism", "X-MESSENGER-OAUTH2" );
- reply->text = g_strdup( jd->oauth2_access_token );
- reply->text_len = strlen( jd->oauth2_access_token );
- }
else if( sup_fb && want_oauth )
{
xt_add_attr( reply, "mechanism", "X-FACEBOOK-PLATFORM" );