diff libpurple/protocols/mxit/profile.c @ 30717:08d9cdac2b3c

A few changes to the Profile. For the user's profile we now also request the 'flags' attribute. The DoB-Locked flag indicates if the user is allowed to change their date-of-birth. If it it locked, make the DoB field read-only. For your buddies profile, request the 'lastseen' attribute. For offline contacts we now show on the profile page when last they were online.
author andrew.victor@mxit.com
date Mon, 19 Jul 2010 08:39:45 +0000
parents b6b0c80f9dde
children 8c586dbcae2d
line wrap: on
line diff
--- a/libpurple/protocols/mxit/profile.c	Fri Jul 16 12:15:28 2010 +0000
+++ b/libpurple/protocols/mxit/profile.c	Mon Jul 19 08:39:45 2010 +0000
@@ -101,6 +101,23 @@
 
 
 /*------------------------------------------------------------------------
+ * Returns timestamp field in date & time format (DD-MM-YYYY HH:MM:SS)
+ *
+ * @param msecs		The timestamps (milliseconds since epoch)
+ * @return			Date & Time in a display'able format.
+ */
+static const char* datetime( int64_t msecs )
+{  
+    time_t secs = msecs / 1000;
+
+    struct tm t;
+    localtime_r( &secs, &t );
+
+	return purple_utf8_strftime( "%d-%m-%Y %H:%M:%S", &t );
+}
+
+
+/*------------------------------------------------------------------------
  * Display the profile information.
  *
  *  @param session		The MXit session object
@@ -138,6 +155,10 @@
 		/* presence */
 		purple_notify_user_info_add_pair( info, _( "Status" ), mxit_convert_presence_to_name( contact->presence ) );
 
+		/* last online */
+		if ( contact->presence == MXIT_PRESENCE_OFFLINE )
+			purple_notify_user_info_add_pair( info, _( "Last Online" ), ( profile->lastonline == 0 ) ? _( "Unknown" ) : datetime( profile->lastonline ) );
+
 		/* mood */
 		if ( contact->mood != MXIT_MOOD_NONE )   
 			purple_notify_user_info_add_pair( info, _( "Mood" ), mxit_convert_mood_to_name( contact->mood ) );