Mercurial > pidgin
comparison src/protocols/msn/dispatch.c @ 5564:187c740f2a4e
[gaim-migrate @ 5966]
Committing what I have so far.
Some new functions, and msn is almost done.
committer: Tailor Script <tailor@pidgin.im>
| author | Christian Hammond <chipx86@chipx86.com> |
|---|---|
| date | Fri, 30 May 2003 18:04:45 +0000 |
| parents | e2e53316a21d |
| children | 952710ac6635 |
comparison
equal
deleted
inserted
replaced
| 5563:9eb5b13fd412 | 5564:187c740f2a4e |
|---|---|
| 28 | 28 |
| 29 static gboolean | 29 static gboolean |
| 30 __ver_cmd(MsnServConn *servconn, const char *command, const char **params, | 30 __ver_cmd(MsnServConn *servconn, const char *command, const char **params, |
| 31 size_t param_count) | 31 size_t param_count) |
| 32 { | 32 { |
| 33 struct gaim_connection *gc = servconn->session->account->gc; | 33 GaimConnection *gc = servconn->session->account->gc; |
| 34 size_t i; | 34 size_t i; |
| 35 gboolean msnp5_found = FALSE; | 35 gboolean msnp5_found = FALSE; |
| 36 | 36 |
| 37 for (i = 1; i < param_count; i++) { | 37 for (i = 1; i < param_count; i++) { |
| 38 if (!strcmp(params[i], "MSNP5")) { | 38 if (!strcmp(params[i], "MSNP5")) { |
| 40 break; | 40 break; |
| 41 } | 41 } |
| 42 } | 42 } |
| 43 | 43 |
| 44 if (!msnp5_found) { | 44 if (!msnp5_found) { |
| 45 hide_login_progress(gc, _("Protocol not supported")); | 45 gaim_connection_error(gc, _("Protocol not supported")); |
| 46 signoff(gc); | |
| 47 | 46 |
| 48 return FALSE; | 47 return FALSE; |
| 49 } | 48 } |
| 50 | 49 |
| 51 if (!msn_servconn_send_command(servconn, "INF", NULL)) { | 50 if (!msn_servconn_send_command(servconn, "INF", NULL)) { |
| 52 hide_login_progress(gc, _("Unable to request INF\n")); | 51 gaim_connection_error(gc, _("Unable to request INF\n")); |
| 53 signoff(gc); | |
| 54 | 52 |
| 55 return FALSE; | 53 return FALSE; |
| 56 } | 54 } |
| 57 | 55 |
| 58 return TRUE; | 56 return TRUE; |
| 60 | 58 |
| 61 static gboolean | 59 static gboolean |
| 62 __inf_cmd(MsnServConn *servconn, const char *command, const char **params, | 60 __inf_cmd(MsnServConn *servconn, const char *command, const char **params, |
| 63 size_t param_count) | 61 size_t param_count) |
| 64 { | 62 { |
| 65 struct gaim_connection *gc = servconn->session->account->gc; | 63 GaimAccount *account = servconn->session->account; |
| 64 GaimConnection *gc = gaim_account_get_connection(account); | |
| 66 char outparams[MSN_BUF_LEN]; | 65 char outparams[MSN_BUF_LEN]; |
| 67 | 66 |
| 68 if (strcmp(params[1], "MD5")) { | 67 if (strcmp(params[1], "MD5")) { |
| 69 hide_login_progress(gc, _("Unable to login using MD5")); | 68 gaim_connection_error(gc, _("Unable to login using MD5")); |
| 70 signoff(gc); | 69 |
| 71 | 70 return FALSE; |
| 72 return FALSE; | 71 } |
| 73 } | 72 |
| 74 | 73 g_snprintf(outparams, sizeof(outparams), "MD5 I %s", |
| 75 g_snprintf(outparams, sizeof(outparams), "MD5 I %s", gc->username); | 74 gaim_account_get_username(account)); |
| 76 | 75 |
| 77 if (!msn_servconn_send_command(servconn, "USR", outparams)) { | 76 if (!msn_servconn_send_command(servconn, "USR", outparams)) { |
| 78 hide_login_progress(gc, _("Unable to send USR\n")); | 77 gaim_connection_error(gc, _("Unable to send USR\n")); |
| 79 signoff(gc); | 78 |
| 80 | 79 return FALSE; |
| 81 return FALSE; | 80 } |
| 82 } | 81 |
| 83 | 82 gaim_connection_update_progress(gc, _("Requesting to send password"), |
| 84 set_login_progress(gc, 3, _("Requesting to send password")); | 83 3, MSN_CONNECT_STEPS); |
| 85 | 84 |
| 86 return TRUE; | 85 return TRUE; |
| 87 } | 86 } |
| 88 | 87 |
| 89 static gboolean | 88 static gboolean |
| 90 __xfr_cmd(MsnServConn *servconn, const char *command, const char **params, | 89 __xfr_cmd(MsnServConn *servconn, const char *command, const char **params, |
| 91 size_t param_count) | 90 size_t param_count) |
| 92 { | 91 { |
| 93 MsnSession *session = servconn->session; | 92 MsnSession *session = servconn->session; |
| 94 struct gaim_connection *gc = servconn->session->account->gc; | 93 GaimConnection *gc = servconn->session->account->gc; |
| 95 char *host; | 94 char *host; |
| 96 int port; | 95 int port; |
| 97 char *c; | 96 char *c; |
| 98 | 97 |
| 99 if (param_count < 2 || strcmp(params[1], "NS")) { | 98 if (param_count < 2 || strcmp(params[1], "NS")) { |
| 100 hide_login_progress(gc, _("Got invalid XFR\n")); | 99 gaim_connection_error(gc, _("Got invalid XFR\n")); |
| 101 signoff(gc); | |
| 102 | 100 |
| 103 return FALSE; | 101 return FALSE; |
| 104 } | 102 } |
| 105 | 103 |
| 106 host = g_strdup(params[2]); | 104 host = g_strdup(params[2]); |
| 123 session->notification_conn = msn_notification_new(session, host, port); | 121 session->notification_conn = msn_notification_new(session, host, port); |
| 124 | 122 |
| 125 g_free(host); | 123 g_free(host); |
| 126 | 124 |
| 127 if (!msn_servconn_connect(session->notification_conn)) { | 125 if (!msn_servconn_connect(session->notification_conn)) { |
| 128 hide_login_progress(gc, _("Unable to transfer")); | 126 gaim_connection_error(gc, _("Unable to transfer")); |
| 129 signoff(gc); | |
| 130 } | 127 } |
| 131 | 128 |
| 132 return FALSE; | 129 return FALSE; |
| 133 } | 130 } |
| 134 | 131 |
| 135 static gboolean | 132 static gboolean |
| 136 __unknown_cmd(MsnServConn *servconn, const char *command, const char **params, | 133 __unknown_cmd(MsnServConn *servconn, const char *command, const char **params, |
| 137 size_t param_count) | 134 size_t param_count) |
| 138 { | 135 { |
| 139 struct gaim_connection *gc = servconn->session->account->gc; | 136 GaimConnection *gc = servconn->session->account->gc; |
| 140 | 137 |
| 141 if (isdigit(*command)) { | 138 if (isdigit(*command)) { |
| 142 char buf[4]; | 139 char buf[4]; |
| 143 | 140 |
| 144 strncpy(buf, command, 4); | 141 strncpy(buf, command, 4); |
| 145 buf[4] = '\0'; | 142 buf[4] = '\0'; |
| 146 | 143 |
| 147 hide_login_progress(gc, (char *)msn_error_get_text(atoi(buf))); | 144 gaim_connection_error(gc, (char *)msn_error_get_text(atoi(buf))); |
| 148 } | 145 } |
| 149 else | 146 else |
| 150 hide_login_progress(gc, _("Unable to parse message.")); | 147 gaim_connection_error(gc, _("Unable to parse message.")); |
| 151 | |
| 152 signoff(gc); | |
| 153 | 148 |
| 154 return FALSE; | 149 return FALSE; |
| 155 } | 150 } |
| 156 | 151 |
| 157 static gboolean | 152 static gboolean |
| 158 __connect_cb(gpointer data, gint source, GaimInputCondition cond) | 153 __connect_cb(gpointer data, gint source, GaimInputCondition cond) |
| 159 { | 154 { |
| 160 MsnServConn *dispatch = data; | 155 MsnServConn *dispatch = data; |
| 161 MsnSession *session = dispatch->session; | 156 MsnSession *session = dispatch->session; |
| 162 struct gaim_connection *gc = session->account->gc; | 157 GaimConnection *gc = session->account->gc; |
| 163 | 158 |
| 164 if (source == -1) { | 159 if (source == -1) { |
| 165 hide_login_progress(session->account->gc, _("Unable to connect")); | 160 gaim_connection_error(session->account->gc, _("Unable to connect")); |
| 166 signoff(session->account->gc); | 161 return FALSE; |
| 167 return FALSE; | 162 } |
| 168 } | 163 |
| 169 | 164 gaim_connection_update_progress(gc, _("Connecting"), 1, MSN_CONNECT_STEPS); |
| 170 set_login_progress(gc, 1, _("Connecting")); | |
| 171 | 165 |
| 172 if (dispatch->fd != source) | 166 if (dispatch->fd != source) |
| 173 dispatch->fd = source; | 167 dispatch->fd = source; |
| 174 | 168 |
| 175 if (!msn_servconn_send_command(dispatch, "VER", | 169 if (!msn_servconn_send_command(dispatch, "VER", |
| 176 "MSNP7 MSNP6 MSNP5 MSNP4 CVR0")) { | 170 "MSNP7 MSNP6 MSNP5 MSNP4 CVR0")) { |
| 177 hide_login_progress(gc, _("Unable to write to server")); | 171 gaim_connection_error(gc, _("Unable to write to server")); |
| 178 signoff(gc); | 172 return FALSE; |
| 179 return FALSE; | 173 } |
| 180 } | 174 |
| 181 | 175 gaim_connection_update_progress(gc, _("Syncing with server"), |
| 182 set_login_progress(session->account->gc, 2, _("Syncing with server")); | 176 2, MSN_CONNECT_STEPS); |
| 183 | 177 |
| 184 return TRUE; | 178 return TRUE; |
| 185 } | 179 } |
| 186 | 180 |
| 187 static void | 181 static void |
| 188 __failed_read_cb(gpointer data, gint source, GaimInputCondition cond) | 182 __failed_read_cb(gpointer data, gint source, GaimInputCondition cond) |
| 189 { | 183 { |
| 190 MsnServConn *dispatch = data; | 184 MsnServConn *dispatch = data; |
| 191 struct gaim_connection *gc; | 185 GaimConnection *gc; |
| 192 | 186 |
| 193 gc = dispatch->session->account->gc; | 187 gc = dispatch->session->account->gc; |
| 194 | 188 |
| 195 hide_login_progress(gc, _("Error reading from server")); | 189 gaim_connection_error(gc, _("Error reading from server")); |
| 196 signoff(gc); | |
| 197 } | 190 } |
| 198 | 191 |
| 199 MsnServConn * | 192 MsnServConn * |
| 200 msn_dispatch_new(MsnSession *session, const char *server, int port) | 193 msn_dispatch_new(MsnSession *session, const char *server, int port) |
| 201 { | 194 { |
