comparison libpurple/protocols/mxit/actions.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents f75041cb3fec
children
comparison
equal deleted inserted replaced
32818:01ff09d4a463 32819:2c6510167895
41 * @param gc The connection object 41 * @param gc The connection object
42 * @param fields The fields from the request pop-up 42 * @param fields The fields from the request pop-up
43 */ 43 */
44 static void mxit_profile_cb( PurpleConnection* gc, PurpleRequestFields* fields ) 44 static void mxit_profile_cb( PurpleConnection* gc, PurpleRequestFields* fields )
45 { 45 {
46 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 46 struct MXitSession* session = purple_connection_get_protocol_data( gc ) ;
47 PurpleRequestField* field = NULL; 47 PurpleRequestField* field = NULL;
48 const char* name = NULL; 48 const char* name = NULL;
49 const char* bday = NULL; 49 const char* bday = NULL;
50 const char* err = NULL; 50 const char* err = NULL;
51 51
82 g_strlcpy( profile->nickname, name, sizeof( profile->nickname ) ); 82 g_strlcpy( profile->nickname, name, sizeof( profile->nickname ) );
83 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROFILE_TYPE_UTF8, profile->nickname ); 83 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_FULLNAME, CP_PROFILE_TYPE_UTF8, profile->nickname );
84 g_string_append( attributes, attrib ); 84 g_string_append( attributes, attrib );
85 acount++; 85 acount++;
86 86
87 /* force hidden if disabled */
88 if ( profile->hidden == FALSE ) {
89 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_HIDENUMBER, CP_PROFILE_TYPE_BOOL, "1" );
90 g_string_append( attributes, attrib );
91 acount++;
92 }
93
94 /* update birthday */ 87 /* update birthday */
95 g_strlcpy( profile->birthday, bday, sizeof( profile->birthday ) ); 88 g_strlcpy( profile->birthday, bday, sizeof( profile->birthday ) );
96 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday ); 89 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_BIRTHDATE, CP_PROFILE_TYPE_UTF8, profile->birthday );
97 g_string_append( attributes, attrib ); 90 g_string_append( attributes, attrib );
98 acount++; 91 acount++;
163 g_string_append( attributes, attrib ); 156 g_string_append( attributes, attrib );
164 acount++; 157 acount++;
165 158
166 /* update where am i */ 159 /* update where am i */
167 name = purple_request_fields_get_string( fields, "whereami" ); 160 name = purple_request_fields_get_string( fields, "whereami" );
168 if ( !name) 161 if ( !name )
169 profile->whereami[0] = '\0'; 162 profile->whereami[0] = '\0';
170 else 163 else
171 g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) ); 164 g_strlcpy( profile->whereami, name, sizeof( profile->whereami ) );
172 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_WHEREAMI, CP_PROFILE_TYPE_UTF8, profile->whereami ); 165 g_snprintf( attrib, sizeof( attrib ), "\01%s\01%i\01%s", CP_PROFILE_WHEREAMI, CP_PROFILE_TYPE_UTF8, profile->whereami );
173 g_string_append( attributes, attrib ); 166 g_string_append( attributes, attrib );
205 * @param action The action object 198 * @param action The action object
206 */ 199 */
207 static void mxit_profile_action( PurplePluginAction* action ) 200 static void mxit_profile_action( PurplePluginAction* action )
208 { 201 {
209 PurpleConnection* gc = (PurpleConnection*) action->context; 202 PurpleConnection* gc = (PurpleConnection*) action->context;
210 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 203 struct MXitSession* session = purple_connection_get_protocol_data( gc );
211 struct MXitProfile* profile = session->profile; 204 struct MXitProfile* profile = session->profile;
212 205
213 PurpleRequestFields* fields = NULL; 206 PurpleRequestFields* fields = NULL;
214 PurpleRequestField* field = NULL; 207 PurpleRequestField* field = NULL;
215 208
302 * @param gc The connection object 295 * @param gc The connection object
303 * @param fields The fields from the request pop-up 296 * @param fields The fields from the request pop-up
304 */ 297 */
305 static void mxit_change_pin_cb( PurpleConnection* gc, PurpleRequestFields* fields ) 298 static void mxit_change_pin_cb( PurpleConnection* gc, PurpleRequestFields* fields )
306 { 299 {
307 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 300 struct MXitSession* session = purple_connection_get_protocol_data( gc );
308 const char* pin = NULL; 301 const char* pin = NULL;
309 const char* pin2 = NULL; 302 const char* pin2 = NULL;
310 const char* err = NULL; 303 const char* err = NULL;
311 int len; 304 int len;
312 int i; 305 int i;
364 * @param action The action object 357 * @param action The action object
365 */ 358 */
366 static void mxit_change_pin_action( PurplePluginAction* action ) 359 static void mxit_change_pin_action( PurplePluginAction* action )
367 { 360 {
368 PurpleConnection* gc = (PurpleConnection*) action->context; 361 PurpleConnection* gc = (PurpleConnection*) action->context;
369 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 362 struct MXitSession* session = purple_connection_get_protocol_data( gc );
370 363
371 PurpleRequestFields* fields = NULL; 364 PurpleRequestFields* fields = NULL;
372 PurpleRequestFieldGroup* group = NULL; 365 PurpleRequestFieldGroup* group = NULL;
373 PurpleRequestField* field = NULL; 366 PurpleRequestField* field = NULL;
374 367
375 purple_debug_info( MXIT_PLUGIN_ID, "mxit_change_pin_action\n" ); 368 purple_debug_info( MXIT_PLUGIN_ID, "mxit_change_pin_action\n" );
376 369
377 fields = purple_request_fields_new(); 370 fields = purple_request_fields_new();
378 group = purple_request_field_group_new(NULL); 371 group = purple_request_field_group_new( NULL );
379 purple_request_fields_add_group(fields, group); 372 purple_request_fields_add_group( fields, group );
380 373
381 /* pin */ 374 /* pin */
382 field = purple_request_field_string_new( "pin", _( "PIN" ), session->acc->password, FALSE ); 375 field = purple_request_field_string_new( "pin", _( "PIN" ), purple_account_get_password( session->acc ), FALSE );
383 purple_request_field_string_set_masked( field, TRUE ); 376 purple_request_field_string_set_masked( field, TRUE );
384 purple_request_field_group_add_field( group, field ); 377 purple_request_field_group_add_field( group, field );
385 378
386 /* verify pin */ 379 /* verify pin */
387 field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), session->acc->password, FALSE ); 380 field = purple_request_field_string_new( "pin2", _( "Verify PIN" ), purple_account_get_password( session->acc ), FALSE );
388 purple_request_field_string_set_masked( field, TRUE ); 381 purple_request_field_string_set_masked( field, TRUE );
389 purple_request_field_group_add_field( group, field ); 382 purple_request_field_group_add_field( group, field );
390 383
391 /* (reference: "libpurple/request.h") */ 384 /* (reference: "libpurple/request.h") */
392 purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ), 385 purple_request_fields( gc, _( "Change PIN" ), _( "Change MXit PIN" ), NULL, fields, _( "Set" ),
400 * @param action The action object 393 * @param action The action object
401 */ 394 */
402 static void mxit_splash_action( PurplePluginAction* action ) 395 static void mxit_splash_action( PurplePluginAction* action )
403 { 396 {
404 PurpleConnection* gc = (PurpleConnection*) action->context; 397 PurpleConnection* gc = (PurpleConnection*) action->context;
405 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 398 struct MXitSession* session = purple_connection_get_protocol_data( gc );
406 399
407 if ( splash_current( session ) != NULL ) 400 if ( splash_current( session ) != NULL )
408 splash_display( session ); 401 splash_display( session );
409 else 402 else
410 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "View Splash" ), _( "There is no splash-screen currently available" ) ); 403 mxit_popup( PURPLE_NOTIFY_MSG_INFO, _( "View Splash" ), _( "There is no splash-screen currently available" ) );
437 * @param action The action object 430 * @param action The action object
438 */ 431 */
439 static void mxit_suggested_friends_action( PurplePluginAction* action ) 432 static void mxit_suggested_friends_action( PurplePluginAction* action )
440 { 433 {
441 PurpleConnection* gc = (PurpleConnection*) action->context; 434 PurpleConnection* gc = (PurpleConnection*) action->context;
442 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 435 struct MXitSession* session = purple_connection_get_protocol_data( gc );
443 const char* profilelist[] = { 436 const char* profilelist[] = {
444 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME, 437 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME,
445 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR, 438 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR,
446 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; 439 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
447 440
454 * 447 *
455 * @param action The action object 448 * @param action The action object
456 */ 449 */
457 static void mxit_user_search_cb( PurpleConnection *gc, const char *input ) 450 static void mxit_user_search_cb( PurpleConnection *gc, const char *input )
458 { 451 {
459 struct MXitSession* session = (struct MXitSession*) gc->proto_data; 452 struct MXitSession* session = purple_connection_get_protocol_data( gc );
460 const char* profilelist[] = { 453 const char* profilelist[] = {
461 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME, 454 CP_PROFILE_BIRTHDATE, CP_PROFILE_GENDER, CP_PROFILE_FULLNAME, CP_PROFILE_FIRSTNAME,
462 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR, 455 CP_PROFILE_LASTNAME, CP_PROFILE_REGCOUNTRY, CP_PROFILE_STATUS, CP_PROFILE_AVATAR,
463 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME }; 456 CP_PROFILE_WHEREAMI, CP_PROFILE_ABOUTME };
464 457
477 470
478 purple_request_input( gc, _( "Search for user" ), 471 purple_request_input( gc, _( "Search for user" ),
479 _( "Search for a MXit contact" ), 472 _( "Search for a MXit contact" ),
480 _( "Type search information" ), 473 _( "Type search information" ),
481 NULL, FALSE, FALSE, NULL, 474 NULL, FALSE, FALSE, NULL,
482 _("_Search"), G_CALLBACK( mxit_user_search_cb ), 475 _( "_Search" ), G_CALLBACK( mxit_user_search_cb ),
483 _("_Cancel"), NULL, 476 _( "_Cancel" ), NULL,
484 purple_connection_get_account( gc ), NULL, NULL, 477 purple_connection_get_account( gc ), NULL, NULL,
485 gc); 478 gc );
486 } 479 }
487 480
488 481
489 /*------------------------------------------------------------------------ 482 /*------------------------------------------------------------------------
490 * Associate actions with the MXit plugin. 483 * Associate actions with the MXit plugin.