Mercurial > pidgin
comparison libpurple/protocols/msn/cmdproc.c @ 30710:f7ee91763c6b
msn: Remove msn_cmdproc_send_quick in favor of msn_cmdproc_send_trans
With this changes whe have an unified and robust way to send commands.
We avoid duplicated code and it's easier to find problems since the code is only
in one place.
author | masca@cpw.pidgin.im |
---|---|
date | Wed, 10 Mar 2010 22:16:04 +0000 |
parents | 4d7dfeae29c6 |
children | 7b310568cd87 |
comparison
equal
deleted
inserted
replaced
30709:4d7dfeae29c6 | 30710:f7ee91763c6b |
---|---|
151 | 151 |
152 msn_servconn_write(servconn, data, len); | 152 msn_servconn_write(servconn, data, len); |
153 | 153 |
154 g_free(data); | 154 g_free(data); |
155 } | 155 } |
156 | |
157 void | |
158 msn_cmdproc_send_quick(MsnCmdProc *cmdproc, const char *command, | |
159 const char *format, ...) | |
160 { | |
161 MsnServConn *servconn; | |
162 char *data; | |
163 char *params = NULL; | |
164 va_list arg; | |
165 size_t len; | |
166 | |
167 g_return_if_fail(cmdproc != NULL); | |
168 g_return_if_fail(command != NULL); | |
169 | |
170 servconn = cmdproc->servconn; | |
171 | |
172 if (!servconn->connected) | |
173 return; | |
174 | |
175 if (format != NULL) | |
176 { | |
177 va_start(arg, format); | |
178 params = g_strdup_vprintf(format, arg); | |
179 va_end(arg); | |
180 } | |
181 | |
182 if (params != NULL) | |
183 data = g_strdup_printf("%s %s\r\n", command, params); | |
184 else | |
185 data = g_strdup_printf("%s\r\n", command); | |
186 | |
187 g_free(params); | |
188 | |
189 len = strlen(data); | |
190 | |
191 show_debug_cmd(cmdproc, FALSE, data); | |
192 | |
193 msn_servconn_write(servconn, data, len); | |
194 | |
195 g_free(data); | |
196 } | |
197 | |
198 | 156 |
199 void | 157 void |
200 msn_cmdproc_process_payload(MsnCmdProc *cmdproc, char *payload, | 158 msn_cmdproc_process_payload(MsnCmdProc *cmdproc, char *payload, |
201 int payload_len) | 159 int payload_len) |
202 { | 160 { |