comparison libpurple/protocols/msn/user.c @ 29351:08296b862f98

Move the three phone numbers from the MsnUser struct into a separate struct that gets added as needed. Makes MsnUser smaller by 2 pointers. In practice nobody has phone numbers
author Mark Doliner <mark@kingant.net>
date Thu, 04 Feb 2010 00:35:15 +0000
parents 99d1b433dba0
children 746bf7d8b34e
comparison
equal deleted inserted replaced
29350:99d1b433dba0 29351:08296b862f98
65 msn_object_destroy(user->msnobj); 65 msn_object_destroy(user->msnobj);
66 66
67 g_free(user->passport); 67 g_free(user->passport);
68 g_free(user->friendly_name); 68 g_free(user->friendly_name);
69 g_free(user->uid); 69 g_free(user->uid);
70 g_free(user->phone.home); 70 if (user->phone) {
71 g_free(user->phone.work); 71 g_free(user->phone->home);
72 g_free(user->phone.mobile); 72 g_free(user->phone->work);
73 g_free(user->phone->mobile);
74 g_free(user->phone);
75 }
73 if (user->media) { 76 if (user->media) {
74 g_free(user->media->artist); 77 g_free(user->media->artist);
75 g_free(user->media->title); 78 g_free(user->media->title);
76 g_free(user->media->album); 79 g_free(user->media->album);
77 g_free(user->media); 80 g_free(user->media);
365 void 368 void
366 msn_user_set_home_phone(MsnUser *user, const char *number) 369 msn_user_set_home_phone(MsnUser *user, const char *number)
367 { 370 {
368 g_return_if_fail(user != NULL); 371 g_return_if_fail(user != NULL);
369 372
370 g_free(user->phone.home); 373 if (!number && !user->phone)
371 user->phone.home = g_strdup(number); 374 return;
375
376 if (user->phone)
377 g_free(user->phone->home);
378 else
379 user->phone = g_new0(MsnUserPhoneInfo, 1);
380
381 user->phone->home = g_strdup(number);
372 } 382 }
373 383
374 void 384 void
375 msn_user_set_work_phone(MsnUser *user, const char *number) 385 msn_user_set_work_phone(MsnUser *user, const char *number)
376 { 386 {
377 g_return_if_fail(user != NULL); 387 g_return_if_fail(user != NULL);
378 388
379 g_free(user->phone.work); 389 if (!number && !user->phone)
380 user->phone.work = g_strdup(number); 390 return;
391
392 if (user->phone)
393 g_free(user->phone->work);
394 else
395 user->phone = g_new0(MsnUserPhoneInfo, 1);
396
397 user->phone->work = g_strdup(number);
381 } 398 }
382 399
383 void 400 void
384 msn_user_set_mobile_phone(MsnUser *user, const char *number) 401 msn_user_set_mobile_phone(MsnUser *user, const char *number)
385 { 402 {
386 g_return_if_fail(user != NULL); 403 g_return_if_fail(user != NULL);
387 404
388 g_free(user->phone.mobile); 405 if (!number && !user->phone)
389 user->phone.mobile = g_strdup(number); 406 return;
407
408 if (user->phone)
409 g_free(user->phone->mobile);
410 else
411 user->phone = g_new0(MsnUserPhoneInfo, 1);
412
413 user->phone->mobile = g_strdup(number);
390 } 414 }
391 415
392 void 416 void
393 msn_user_set_clientid(MsnUser *user, guint clientid) 417 msn_user_set_clientid(MsnUser *user, guint clientid)
394 { 418 {
459 const char * 483 const char *
460 msn_user_get_home_phone(const MsnUser *user) 484 msn_user_get_home_phone(const MsnUser *user)
461 { 485 {
462 g_return_val_if_fail(user != NULL, NULL); 486 g_return_val_if_fail(user != NULL, NULL);
463 487
464 return user->phone.home; 488 return user->phone ? user->phone->home : NULL;
465 } 489 }
466 490
467 const char * 491 const char *
468 msn_user_get_work_phone(const MsnUser *user) 492 msn_user_get_work_phone(const MsnUser *user)
469 { 493 {
470 g_return_val_if_fail(user != NULL, NULL); 494 g_return_val_if_fail(user != NULL, NULL);
471 495
472 return user->phone.work; 496 return user->phone ? user->phone->work : NULL;
473 } 497 }
474 498
475 const char * 499 const char *
476 msn_user_get_mobile_phone(const MsnUser *user) 500 msn_user_get_mobile_phone(const MsnUser *user)
477 { 501 {
478 g_return_val_if_fail(user != NULL, NULL); 502 g_return_val_if_fail(user != NULL, NULL);
479 503
480 return user->phone.mobile; 504 return user->phone ? user->phone->mobile : NULL;
481 } 505 }
482 506
483 guint 507 guint
484 msn_user_get_clientid(const MsnUser *user) 508 msn_user_get_clientid(const MsnUser *user)
485 { 509 {