aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-05-13 05:05:01 -0300
committerdequis <dx@dxzone.com.ar>2015-05-13 05:05:01 -0300
commit99fe03055377745e7d549f63379ff99e65b04018 (patch)
tree80faf282387fdc8dcb27eff6af7bc2e45c612982
parenta7336698d6fa7b561ac56166eef3ec07adcbee41 (diff)
msn: Implement sending typing notifications
Also remove some old unused debug stuff
-rw-r--r--protocols/msn/msn.c14
-rw-r--r--protocols/msn/msn.h21
-rw-r--r--protocols/msn/ns.c22
3 files changed, 19 insertions, 38 deletions
diff --git a/protocols/msn/msn.c b/protocols/msn/msn.c
index 7d0805a7..4acff23a 100644
--- a/protocols/msn/msn.c
+++ b/protocols/msn/msn.c
@@ -143,16 +143,8 @@ static void msn_logout(struct im_connection *ic)
static int msn_buddy_msg(struct im_connection *ic, char *who, char *message, int away)
{
struct bee_user *bu = bee_user_by_handle(ic->bee, ic, who);
-
-#ifdef DEBUG
- if (strcmp(who, "raw") == 0) {
- msn_ns_write(ic, -1, "%s\r\n", message);
- return 0;
- }
-#endif
-
- msn_ns_sendmessage(ic, bu, message);
- return(0);
+ msn_ns_send_message(ic, bu, message);
+ return 0;
}
static GList *msn_away_states(struct im_connection *ic)
@@ -276,7 +268,7 @@ static int msn_send_typing(struct im_connection *ic, char *who, int typing)
if (!(bu->flags & BEE_USER_ONLINE)) {
return 0;
} else if (typing & OPT_TYPING) {
- return(msn_buddy_msg(ic, who, TYPING_NOTIFICATION_MESSAGE, 0));
+ return msn_ns_send_typing(ic, bu);
} else {
return 1;
}
diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h
index b76fbd40..02ba7a0d 100644
--- a/protocols/msn/msn.h
+++ b/protocols/msn/msn.h
@@ -26,17 +26,6 @@
#ifndef _MSN_H
#define _MSN_H
-/* Some hackish magicstrings to make special-purpose messages/switchboards.
- */
-#define TYPING_NOTIFICATION_MESSAGE "\r\r\rBEWARE, ME R TYPINK MESSAGE!!!!\r\r\r"
-#define GROUPCHAT_SWITCHBOARD_MESSAGE "\r\r\rME WANT TALK TO MANY PEOPLE\r\r\r"
-
-#ifdef DEBUG_MSN
-#define debug(text ...) imcb_log(ic, text);
-#else
-#define debug(text ...)
-#endif
-
/* This should be MSN Messenger 7.0.0813
#define MSNP11_PROD_KEY "CFHUR$52U_{VIX5T"
#define MSNP11_PROD_ID "PROD0101{0RM?UBW"
@@ -75,7 +64,7 @@
#define MSN_MESSAGE_HEADERS MSN_BASE_HEADERS \
"Messaging: 2.0\r\n" \
- "Message-Type: Text\r\n" \
+ "Message-Type: %s\r\n" \
"Content-Length: %zd\r\n" \
"Content-Type: text/plain; charset=UTF-8\r\n" \
"X-MMS-IM-Format: FN=Segoe%%20UI; EF=; CO=0; CS=0; PF=0\r\n" \
@@ -101,11 +90,6 @@
"<sep n=\"IM\"><Capabilities>%d:%d</Capabilities></sep>" \
"</user>"
-#define MSN_TYPING_HEADERS "MIME-Version: 1.0\r\n" \
- "Content-Type: text/x-msmsgscontrol\r\n" \
- "TypingUser: %s\r\n" \
- "\r\n\r\n"
-
#define PROFILE_URL "http://members.msn.com/"
typedef enum {
@@ -234,7 +218,8 @@ void msn_ns_close(struct msn_data *handler);
void msn_auth_got_passport_token(struct im_connection *ic, const char *token, const char *error);
void msn_auth_got_contact_list(struct im_connection *ic);
int msn_ns_finish_login(struct im_connection *ic);
-int msn_ns_sendmessage(struct im_connection *ic, struct bee_user *bu, const char *text);
+int msn_ns_send_typing(struct im_connection *ic, struct bee_user *bu);
+int msn_ns_send_message(struct im_connection *ic, struct bee_user *bu, const char *text);
int msn_ns_command(struct msn_data *md, char **cmd, int num_parts);
int msn_ns_message(struct msn_data *md, char *msg, int msglen, char **cmd, int num_parts);
diff --git a/protocols/msn/ns.c b/protocols/msn/ns.c
index 906208a7..d3fde5d1 100644
--- a/protocols/msn/ns.c
+++ b/protocols/msn/ns.c
@@ -723,21 +723,25 @@ int msn_ns_finish_login(struct im_connection *ic)
return 1;
}
-// TODO: typing notifications, nudges lol, etc
-int msn_ns_sendmessage(struct im_connection *ic, bee_user_t *bu, const char *text)
+static int msn_ns_send_sdg(struct im_connection *ic, bee_user_t *bu, const char *message_type, const char *text)
{
struct msn_data *md = ic->proto_data;
int retval = 0;
char *buf;
- if (strncmp(text, "\r\r\r", 3) == 0) {
- /* Err. Shouldn't happen but I guess it can. Don't send others
- any of the "SHAKE THAT THING" messages. :-D */
- return 1;
- }
-
- buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, strlen(text), text);
+ buf = g_strdup_printf(MSN_MESSAGE_HEADERS, bu->handle, ic->acc->user, md->uuid, message_type, strlen(text), text);
retval = msn_ns_write(ic, -1, "SDG %d %zd\r\n%s", ++md->trId, strlen(buf), buf);
g_free(buf);
return retval;
}
+
+int msn_ns_send_typing(struct im_connection *ic, bee_user_t *bu)
+{
+ return msn_ns_send_sdg(ic, bu, "Control/Typing", "");
+}
+
+int msn_ns_send_message(struct im_connection *ic, bee_user_t *bu, const char *text)
+{
+ return msn_ns_send_sdg(ic, bu, "Text", text);
+}
+