soc.2008.vv: 77e249bc: Convert serv_* media functions to purple...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Fri Jul 18 23:16:11 EDT 2008


-----------------------------------------------------------------
Revision: 77e249bc561fc09bc5fe8f9c6f8b573701b5d63d
Ancestor: d462febbc44194afbda3bdd17d63a3777dd21ee5
Author: maiku at soc.pidgin.im
Date: 2008-07-19T03:10:00
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/77e249bc561fc09bc5fe8f9c6f8b573701b5d63d

Modified files:
        finch/gntmedia.c libpurple/media.h libpurple/prpl.c
        libpurple/prpl.h libpurple/server.c libpurple/server.h
        pidgin/gtkconv.c

ChangeLog: 

Convert serv_* media functions to purple_prpl_* functions.

-------------- next part --------------
============================================================
--- finch/gntmedia.c	4497102a55b3c20a62b493df4d0938911d2ddb5f
+++ finch/gntmedia.c	f810100beffc4da865820d6b17d4f3c0ffd2e8fb
@@ -433,10 +433,10 @@ call_cmd_cb(PurpleConversation *conv, co
 call_cmd_cb(PurpleConversation *conv, const char *cmd, char **args,
 		char **eror, gpointer data)
 {
-	PurpleConnection *gc = purple_conversation_get_gc(conv);
+	PurpleAccount *account = purple_conversation_get_account(conv);
 
 	PurpleMedia *media =
-		serv_initiate_media(gc,
+		purple_prpl_initiate_media(account,
 							purple_conversation_get_name(conv),
 							PURPLE_MEDIA_RECV_AUDIO & PURPLE_MEDIA_SEND_AUDIO);
 
============================================================
--- libpurple/media.h	a67d3d4e8d7930f42022f3275ebdc270b25694ef
+++ libpurple/media.h	08b3cb1921a757afed555e535277a1f3c7b9c8b4
@@ -50,6 +50,12 @@ typedef struct _PurpleMediaSession Purpl
 typedef struct _PurpleMediaPrivate PurpleMediaPrivate;
 typedef struct _PurpleMediaSession PurpleMediaSession;
 
+#else
+
+typedef void PurpleMedia;
+
+#endif /* USE_VV */
+
 typedef enum {
 	PURPLE_MEDIA_NONE	= 0,
 	PURPLE_MEDIA_RECV_AUDIO = 1 << 0,
@@ -60,6 +66,8 @@ typedef enum {
 	PURPLE_MEDIA_VIDEO = PURPLE_MEDIA_RECV_VIDEO | PURPLE_MEDIA_SEND_VIDEO
 } PurpleMediaStreamType;
 
+#ifdef USE_VV
+
 struct _PurpleMediaClass
 {
 	GObjectClass parent_class;
============================================================
--- libpurple/prpl.c	20e29dbf2ce48b137596ce894cb6887f667a1383
+++ libpurple/prpl.c	5e45b99fd797e05e2e0c75ffcc2329647c391ae1
@@ -411,3 +411,61 @@ purple_find_prpl(const char *id)
 
 	return NULL;
 }
+
+
+
+PurpleMedia *
+purple_prpl_initiate_media(PurpleAccount *account,
+			   const char *who,
+			   PurpleMediaStreamType type)
+{
+#ifdef USE_VV
+	PurpleConnection *gc = NULL;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+
+	if (account)
+		gc = purple_account_get_connection(account);
+	if (gc)
+		prpl = purple_connection_get_prpl(gc);
+	if (prpl)
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+
+	if (prpl_info && prpl_info->initiate_media) {
+		/* should check that the protocol supports this media type here? */
+		return prpl_info->initiate_media(gc, who, type);
+	} else {
+		return NULL;
+	}
+#else
+	return NULL;
+#endif
+}
+
+gboolean
+purple_prpl_can_do_media(PurpleAccount *account,
+			 const char *who, 
+			 PurpleMediaStreamType type)
+{
+#ifdef USE_VV
+	PurpleConnection *gc = NULL;
+	PurplePlugin *prpl = NULL;
+	PurplePluginProtocolInfo *prpl_info = NULL;
+	
+	if (account)
+		gc = purple_account_get_connection(account);
+	if (gc)
+		prpl = purple_connection_get_prpl(gc);
+	if (prpl)
+		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
+	
+	if (prpl_info && prpl_info->can_do_media) {
+		return prpl_info->can_do_media(gc, who, type);
+	} else {
+		return FALSE;
+	}
+#else
+	return FALSE;
+#endif
+}
+
============================================================
--- libpurple/prpl.h	02abb4007fb4d05e169e46732e40d50ea46751df
+++ libpurple/prpl.h	c92d8422169b2fa0133312c30b0ea63acc5538f3
@@ -442,23 +442,10 @@ struct _PurplePluginProtocolInfo
 	 */
 	GHashTable *(*get_account_text_table)(PurpleAccount *account);
 
-#ifdef USE_VV
 	/** Initiate media with the given buddy */
 	PurpleMedia  *(*initiate_media)(PurpleConnection *conn, const char *who, PurpleMediaStreamType type);
 
 	gboolean (*can_do_media)(PurpleConnection *conn, const char *who, PurpleMediaStreamType type);
-    
-    /*
-	gboolean (*can_receive_video)(PurpleConnection *conn, const char *who);
-	gboolean (*can_send_video)(PurpleConnection *conn, const char *who);
-	gboolean (*can_receive_audio)(PurpleConnection *conn, const char *who);
-	gboolean (*can_send_audio)(PurpleConnection *conn, const char *who);
-	*/
-    
-#else
-	void (*initiate_media)(void);
-	void (*can_do_media)(void);
-#endif
 };
 
 #define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \
@@ -712,6 +699,32 @@ GList *purple_prpl_get_statuses(PurpleAc
  */
 GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence);
 
+/**
+ * Determines if the contact supports the given media session type.
+ *
+ * @param account The account the user is on.
+ * @param who The name of the contact to check capabilities for.
+ * @param type The type of media session to check for.
+ *
+ * @return @c TRUE if the contact supports the session type, else @c FALSE.
+ */
+gboolean purple_prpl_can_do_media(PurpleAccount *account,
+				  const char *who, 
+				  PurpleMediaStreamType type);
+
+/**
+ * Initiates a media session with the given contact.
+ *
+ * @param account The account the user is on.
+ * @param who The name of the contact to start a session with.
+ * @param type The type of media session to start.
+ *
+ * @return The newly created session object.
+ */
+PurpleMedia *purple_prpl_initiate_media(PurpleAccount *account,
+					const char *who,
+					PurpleMediaStreamType type);
+
 /*@}*/
 
 /**************************************************************************/
============================================================
--- libpurple/server.c	db0655120056a8e88d0b309734ac6916fc6f6d06
+++ libpurple/server.c	c27765b53a9d0c8bebfa5e522ef6bdeb4f8064dd
@@ -1057,57 +1057,3 @@ void serv_send_file(PurpleConnection *gc
 	}
 }
 
-#ifdef USE_VV
-PurpleMedia *serv_initiate_media(PurpleConnection *gc, const char *who,
-								 PurpleMediaStreamType type)
-{
-	PurplePlugin *prpl = NULL;
-	PurplePluginProtocolInfo *prpl_info = NULL;
-
-	if (gc)
-		prpl = purple_connection_get_prpl(gc);
-	if (prpl)
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-
-	if (prpl_info && prpl_info->initiate_media) {
-		/* should check that the protol supports this media type here.... */
-		return prpl_info->initiate_media(gc, who, type);
-	} else {
-		return NULL;
-	}
-}
-
-gboolean
-serv_can_do_media(PurpleConnection *gc, const char *who, 
-                  PurpleMediaStreamType type)
-{
-    PurplePlugin *prpl = NULL;
-	PurplePluginProtocolInfo *prpl_info = NULL;
-	
-	if (gc)
-		prpl = purple_connection_get_prpl(gc);
-	if (prpl)
-		prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
-	
-	if (prpl_info && prpl_info->can_do_media) {
-		/* should check that the protol supports this media type here.... */
-		return prpl_info->can_do_media(gc, who, type);
-	} else {
-		return FALSE;
-	}
-}
-#else
-void *
-serv_initiate_media(void *gc, void *who, void *type)
-{
-	purple_debug_info("serv", "Blank serv_initiate_media called\n");
-	return NULL;
-}
-
-void *
-serv_can_do_media(void *gc, void *who, void *type)
-{
-	purple_debug_info("serv", "Blank serv_can_do_media called\n");
-	return NULL;
-}
-#endif /* USE_VV */
============================================================
--- libpurple/server.h	32c214f25e2ceb1e414e2b46d168c143d1d92107
+++ libpurple/server.h	82dd7009428122bf12d500af11edd0a276755da4
@@ -183,17 +183,6 @@ void serv_send_file(PurpleConnection *gc
 					  PurpleMessageFlags flags, const char *message, time_t mtime);
 void serv_send_file(PurpleConnection *gc, const char *who, const char *file);
 
-#ifdef USE_VV
-PurpleMedia *serv_initiate_media(PurpleConnection *gc, const char *who,
-						  PurpleMediaStreamType type);
-gboolean serv_can_do_media(PurpleConnection *gc, const char *who, 
-                           PurpleMediaStreamType type);
-#else
-/* hmm, is this really nice? */
-void *serv_initiate_media(void*, void*, void*);
-void *serv_can_do_media(void *, void *, void *);
-#endif
-	
 #ifdef __cplusplus
 }
 #endif
============================================================
--- pidgin/gtkconv.c	ca8c89c834c116037a46d41bfb6d922cb4e1d5df
+++ pidgin/gtkconv.c	5cf4dacd65b4268f45f7d10df59b98f8c823c323
@@ -6380,13 +6380,17 @@ gray_stuff_out(PidginConversation *gtkco
 #ifdef USE_VV
 		/* check if account support voice calls, and if the current buddy
 			supports it */
-		if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
-			gboolean audio = serv_can_do_media(gc, purple_conversation_get_name(conv), 
-							   PURPLE_MEDIA_AUDIO);
-			gboolean video = serv_can_do_media(gc, purple_conversation_get_name(conv), 
-							   PURPLE_MEDIA_VIDEO);
-			gboolean av = serv_can_do_media(gc, purple_conversation_get_name(conv),
-							PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
+		if (account != NULL && purple_conversation_get_type(conv)
+					== PURPLE_CONV_TYPE_IM) {
+			gboolean audio = purple_prpl_can_do_media(account,
+					purple_conversation_get_name(conv),
+					PURPLE_MEDIA_AUDIO);
+			gboolean video = purple_prpl_can_do_media(account,
+					purple_conversation_get_name(conv),
+					PURPLE_MEDIA_VIDEO);
+			gboolean av = purple_prpl_can_do_media(account,
+					purple_conversation_get_name(conv),
+					PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
 
 			gtk_widget_set_sensitive(win->menu.audio_call, audio ? TRUE : FALSE);
 			gtk_widget_set_sensitive(win->menu.video_call, video ? TRUE : FALSE);
@@ -7684,12 +7688,12 @@ menu_initiate_audio_call_cb(gpointer dat
 {
 	PidginWindow *win = (PidginWindow *)data;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
-	PurpleConnection *gc = purple_conversation_get_gc(conv);
+	PurpleAccount *account = purple_conversation_get_account(conv);
 
 	PurpleMedia *media =
-		serv_initiate_media(gc,
-				    purple_conversation_get_name(conv),
-				    PURPLE_MEDIA_AUDIO);
+		purple_prpl_initiate_media(account,
+					   purple_conversation_get_name(conv),
+					   PURPLE_MEDIA_AUDIO);
 
 	if (media)
 		purple_media_wait(media);
@@ -7700,12 +7704,12 @@ menu_initiate_video_call_cb(gpointer dat
 {
 	PidginWindow *win = (PidginWindow *)data;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
-	PurpleConnection *gc = purple_conversation_get_gc(conv);
+	PurpleAccount *account = purple_conversation_get_account(conv);
 
 	PurpleMedia *media =
-		serv_initiate_media(gc,
-				    purple_conversation_get_name(conv),
-				    PURPLE_MEDIA_VIDEO);
+		purple_prpl_initiate_media(account,
+					   purple_conversation_get_name(conv),
+					   PURPLE_MEDIA_VIDEO);
 
 	if (media)
 		purple_media_wait(media);
@@ -7716,12 +7720,12 @@ menu_initiate_audio_video_call_cb(gpoint
 {
 	PidginWindow *win = (PidginWindow *)data;
 	PurpleConversation *conv = pidgin_conv_window_get_active_conversation(win);
-	PurpleConnection *gc = purple_conversation_get_gc(conv);
+	PurpleAccount *account = purple_conversation_get_account(conv);
 
 	PurpleMedia *media =
-		serv_initiate_media(gc,
-				    purple_conversation_get_name(conv),
-				    PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
+		purple_prpl_initiate_media(account,
+					   purple_conversation_get_name(conv),
+					   PURPLE_MEDIA_AUDIO | PURPLE_MEDIA_VIDEO);
 
 	if (media)
 		purple_media_wait(media);


More information about the Commits mailing list