comparison libpurple/protocols/msn/cmdproc.c @ 28243:28485b9ea656

Simplify. A lot of these checks aren't necessary because msn_table_new() always creates these hash tables.
author Mark Doliner <mark@kingant.net>
date Thu, 13 Aug 2009 02:32:33 +0000
parents 9ff5bf0dc670
children 33b4ae796648
comparison
equal deleted inserted replaced
28242:e0dc076ba642 28243:28485b9ea656
331 if (trans->timer) { 331 if (trans->timer) {
332 purple_timeout_remove(trans->timer); 332 purple_timeout_remove(trans->timer);
333 trans->timer = 0; 333 trans->timer = 0;
334 } 334 }
335 335
336 if (g_ascii_isdigit(cmd->command[0])) 336 if (g_ascii_isdigit(cmd->command[0]) && trans != NULL)
337 { 337 {
338 if (trans != NULL) 338 MsnErrorCb error_cb;
339 { 339 int error;
340 MsnErrorCb error_cb; 340
341 int error; 341 error = atoi(cmd->command);
342 342
343 error = atoi(cmd->command); 343 error_cb = trans->error_cb;
344 344 if (error_cb == NULL)
345 error_cb = trans->error_cb; 345 error_cb = g_hash_table_lookup(cmdproc->cbs_table->errors, trans->command);
346 if (error_cb == NULL) 346
347 error_cb = g_hash_table_lookup(cmdproc->cbs_table->errors, trans->command); 347 if (error_cb != NULL)
348 348 error_cb(cmdproc, trans, error);
349 if (error_cb != NULL) 349 else
350 error_cb(cmdproc, trans, error); 350 msn_error_handle(cmdproc->session, error);
351 else 351
352 msn_error_handle(cmdproc->session, error); 352 return;
353 353 }
354 return; 354
355 } 355 cb = g_hash_table_lookup(cmdproc->cbs_table->async, cmd->command);
356 } 356
357 357 if (cb == NULL && trans != NULL && trans->callbacks != NULL)
358 if (cmdproc->cbs_table->async != NULL) 358 cb = g_hash_table_lookup(trans->callbacks, cmd->command);
359 cb = g_hash_table_lookup(cmdproc->cbs_table->async, cmd->command); 359
360 360 if (cb == NULL)
361 if (cb == NULL && trans != NULL)
362 {
363 if (trans->callbacks != NULL)
364 cb = g_hash_table_lookup(trans->callbacks, cmd->command);
365 }
366
367 if (cb == NULL && cmdproc->cbs_table->fallback != NULL)
368 cb = g_hash_table_lookup(cmdproc->cbs_table->fallback, cmd->command); 361 cb = g_hash_table_lookup(cmdproc->cbs_table->fallback, cmd->command);
369 362
370 if (cb != NULL) 363 if (cb != NULL)
371 {
372 cb(cmdproc, cmd); 364 cb(cmdproc, cmd);
373 }
374 else 365 else
375 {
376 purple_debug_warning("msn", "Unhandled command '%s'\n", 366 purple_debug_warning("msn", "Unhandled command '%s'\n",
377 cmd->command); 367 cmd->command);
378 }
379 368
380 if (trans != NULL && trans->pendent_cmd != NULL) 369 if (trans != NULL && trans->pendent_cmd != NULL)
381 msn_transaction_unqueue_cmd(trans, cmdproc); 370 msn_transaction_unqueue_cmd(trans, cmdproc);
382 } 371 }
383 372