/soc/2013/ankitkv/gobjectification: 91be147083c6: Started GObjec...

Ankit Vani a at nevitus.org
Thu Sep 5 12:19:54 EDT 2013


Changeset: 91be147083c660f31c922dcdaa6cd56a011b05d9
Author:	 Ankit Vani <a at nevitus.org>
Date:	 2013-09-05 21:34 +0530
Branch:	 soc.2013.gobjectification
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/91be147083c6

Description:

Started GObjectification of PurpleXfer.
* Renamed ft.[ch] to xfer.[ch]
* Renamed FT.xs to Xfer.xs
* Renamed PurpleXferStatusType to PurpleXferStatus
* Added PurpleXferIoOps
* Removed purple_xfer_set_*_fnc() and used purple_xfer_set_io_ops() instead.
* Renamed purple_xfer_get_type() to purple_xfer_get_xfer_type()

diffstat:

 libpurple/Makefile.am                        |   17 +-
 libpurple/plugins/perl/common/MANIFEST       |    2 +-
 libpurple/plugins/perl/common/Makefile.mingw |    2 +-
 libpurple/plugins/perl/common/FT.xs          |   12 +-
 libpurple/plugins/perl/common/module.h       |    6 +-
 libpurple/plugins/perl/common/typemap        |    2 +-
 libpurple/ft.c                               |   85 +++++++--
 libpurple/ft.h                               |  238 ++++++++------------------
 8 files changed, 155 insertions(+), 209 deletions(-)

diffs (truncated from 742 to 300 lines):

diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -56,7 +56,6 @@ purple_coresources = \
 	debug.c \
 	desktopitem.c \
 	eventloop.c \
-	ft.c \
 	hash.c \
 	http.c \
 	idle.c \
@@ -104,8 +103,9 @@ purple_coresources = \
 	upnp.c \
 	util.c \
 	version.c \
-	xmlnode.c \
-	whiteboard.c
+	whiteboard.c \
+	xfer.c \
+	xmlnode.c
 
 purple_builtsources = \
 	enums.c \
@@ -132,7 +132,6 @@ purple_coreheaders = \
 	debug.h \
 	desktopitem.h \
 	eventloop.h \
-	ft.h \
 	hash.h \
 	http.h \
 	idle.h \
@@ -175,8 +174,9 @@ purple_coreheaders = \
 	theme-manager.h \
 	upnp.h \
 	util.h \
-	xmlnode.h \
-	whiteboard.h
+	whiteboard.h \
+	xfer.h \
+	xmlnode.h
 
 purple_mediaheaders = \
 	backend-iface.h \
@@ -192,7 +192,8 @@ purple_enumheaders = \
 	connection.h \
 	conversation.h \
 	conversationtypes.h \
-	status.h
+	status.h \
+	xfer.h
 
 marshallers.h: marshallers.list
 	$(AM_V_GEN)$(GLIB_GENMARSHAL) --prefix=purple_smarshal $(srcdir)/marshallers.list --header > marshallers.h
@@ -231,7 +232,7 @@ dbus_headers  = dbus-bindings.h dbus-pur
 
 dbus_exported = dbus-useful.h dbus-define-api.h account.h accounts.h blistnode.h \
                 blistnodetypes.h buddylist.h buddyicon.h connection.h conversation.h \
-                conversationtypes.h conversations.h core.h ft.h log.h notify.h \
+                conversationtypes.h conversations.h core.h xfer.h log.h notify.h \
                 prefs.h presence.h roomlist.h savedstatuses.h smiley.h status.h \
                 server.h util.h xmlnode.h prpl.h
 
diff --git a/libpurple/plugins/perl/common/MANIFEST b/libpurple/plugins/perl/common/MANIFEST
--- a/libpurple/plugins/perl/common/MANIFEST
+++ b/libpurple/plugins/perl/common/MANIFEST
@@ -7,7 +7,6 @@ Cmds.xs
 Connection.xs
 Conversation.xs
 Debug.xs
-FT.xs
 Hash.xs
 ImgStore.xs
 Log.xs
@@ -34,6 +33,7 @@ Sound.xs
 Status.xs
 Stringref.xs
 Util.xs
+Xfer.xs
 XMLNode.xs
 MANIFEST
 typemap
diff --git a/libpurple/plugins/perl/common/Makefile.mingw b/libpurple/plugins/perl/common/Makefile.mingw
--- a/libpurple/plugins/perl/common/Makefile.mingw
+++ b/libpurple/plugins/perl/common/Makefile.mingw
@@ -47,7 +47,6 @@ XS_FILES =		Account.xs \
 				Conversation.xs \
 				Core.xs \
 				Debug.xs \
-				FT.xs \
 				Hash.xs \
 				Idle.xs \
 				Purple.xs \
@@ -74,6 +73,7 @@ XS_FILES =		Account.xs \
 				Stringref.xs \
 				Util.xs \
 				Whiteboard.xs \
+				Xfer.xs \
 				XMLNode.xs
 
 #FALLBACKS =	const-c.inc const-xs.inc
diff --git a/libpurple/plugins/perl/common/FT.xs b/libpurple/plugins/perl/common/Xfer.xs
rename from libpurple/plugins/perl/common/FT.xs
rename to libpurple/plugins/perl/common/Xfer.xs
--- a/libpurple/plugins/perl/common/FT.xs
+++ b/libpurple/plugins/perl/common/Xfer.xs
@@ -104,12 +104,12 @@ size_t
 purple_xfer_get_size(xfer)
 	Purple::Xfer xfer
 
-Purple::XferStatusType
+Purple::XferStatus
 purple_xfer_get_status(xfer)
 	Purple::Xfer xfer
 
 Purple::XferType
-purple_xfer_get_type(xfer)
+purple_xfer_get_xfer_type(xfer)
 	Purple::Xfer xfer
 
 gboolean 
@@ -126,10 +126,6 @@ purple_xfer_read(xfer, buffer)
 	guchar **buffer
 
 void 
-purple_xfer_ref(xfer)
-	Purple::Xfer xfer
-
-void 
 purple_xfer_request(xfer)
 	Purple::Xfer xfer
 
@@ -168,10 +164,6 @@ purple_xfer_set_size(xfer, size)
 	size_t size
 
 void 
-purple_xfer_unref(xfer)
-	Purple::Xfer xfer
-
-void 
 purple_xfer_update_progress(xfer)
 	Purple::Xfer xfer
 
diff --git a/libpurple/plugins/perl/common/module.h b/libpurple/plugins/perl/common/module.h
--- a/libpurple/plugins/perl/common/module.h
+++ b/libpurple/plugins/perl/common/module.h
@@ -43,7 +43,7 @@ typedef struct group *Purple__Group;
 #include "debug.h"
 #include "desktopitem.h"
 #include "eventloop.h"
-#include "ft.h"
+#include "xfer.h"
 #ifdef PURPLE_GTKPERL
 #include "gtkaccount.h"
 #include "gtkblist.h"
@@ -142,10 +142,10 @@ typedef PurpleDesktopItemType		Purple__D
 /* eventloop.h */
 typedef PurpleInputCondition *		Purple__InputCondition;
 
-/* ft.h */
+/* xfer.h */
 typedef PurpleXfer *			Purple__Xfer;
 typedef PurpleXferType			Purple__XferType;
-typedef PurpleXferStatusType		Purple__XferStatusType;
+typedef PurpleXferStatus		Purple__XferStatus;
 
 
 #ifdef PURPLE_GTKPERL
diff --git a/libpurple/plugins/perl/common/typemap b/libpurple/plugins/perl/common/typemap
--- a/libpurple/plugins/perl/common/typemap
+++ b/libpurple/plugins/perl/common/typemap
@@ -152,7 +152,7 @@ Purple::Util::InfoFieldFormatCallback	T_
 
 Purple::Xfer				T_PurpleObj
 Purple::XferType				T_IV
-Purple::XferStatusType			T_IV
+Purple::XferStatus			T_IV
 
 Purple::XMLNode				T_PurpleObj
 XMLNode::Type				T_IV
diff --git a/libpurple/ft.c b/libpurple/xfer.c
rename from libpurple/ft.c
rename to libpurple/xfer.c
--- a/libpurple/ft.c
+++ b/libpurple/xfer.c
@@ -1,5 +1,5 @@
 /**
- * @file ft.c File Transfer API
+ * @file xfer.c File Transfer API
  */
 
 /* purple
@@ -25,7 +25,7 @@
  */
 #include "internal.h"
 #include "dbus-maybe.h"
-#include "ft.h"
+#include "xfer.h"
 #include "network.h"
 #include "notify.h"
 #include "prefs.h"
@@ -37,16 +37,61 @@
 #define FT_INITIAL_BUFFER_SIZE 4096
 #define FT_MAX_BUFFER_SIZE     65535
 
+#define PURPLE_XFER_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE((obj), PURPLE_TYPE_XFER, PurpleXferPrivate))
+
+/** @copydoc _PurpleXferPrivate */
+typedef struct _PurpleXferPrivate  PurpleXferPrivate;
+
 static PurpleXferUiOps *xfer_ui_ops = NULL;
 static GList *xfers;
 
-/*
+/* TODO remove.
  * A hack to store more data since we can't extend the size of PurpleXfer
  * easily.
  */
 static GHashTable *xfers_data = NULL;
 
-typedef struct _PurpleXferPrivData {
+/** Private data for a file transfer */
+struct _PurpleXferPrivate {
+	PurpleXferType type;         /**< The type of transfer.               */
+
+	PurpleAccount *account;      /**< The account.                        */
+
+	char *who;                   /**< The person on the other end of the
+	                                  transfer.                           */
+
+	char *message;               /**< A message sent with the request     */
+	char *filename;              /**< The name sent over the network.     */
+	char *local_filename;        /**< The name on the local hard drive.   */
+	goffset size;                /**< The size of the file.               */
+
+	FILE *dest_fp;               /**< The destination file pointer.       */
+
+	char *remote_ip;             /**< The remote IP address.              */
+	int local_port;              /**< The local port.                     */
+	int remote_port;             /**< The remote port.                    */
+
+	int fd;                      /**< The socket file descriptor.         */
+	int watcher;                 /**< Watcher.                            */
+
+	goffset bytes_sent;          /**< The number of bytes sent.           */
+	goffset bytes_remaining;     /**< The number of bytes remaining.      */
+	time_t start_time;           /**< When the transfer of data began.    */
+	time_t end_time;             /**< When the transfer of data ended.    */
+
+	size_t current_buffer_size;  /**< This gradually increases for fast
+	                                   network connections.               */
+
+	PurpleXferStatus status;     /**< File Transfer's status.             */
+
+	PurpleXferIoOps *ops;        /**< I/O operations.                     */
+	PurpleXferUiOps *ui_ops;     /**< UI-specific operations.             */
+
+	void *proto_data;            /**< prpl-specific data.
+	                                  TODO Remove this, and use
+	                                       protocol-specific subclasses   */
+
 	/*
 	 * Used to moderate the file transfer when either the read/write ui_ops are
 	 * set or fd is not set. In those cases, the UI/prpl call the respective
@@ -61,17 +106,17 @@ typedef struct _PurpleXferPrivData {
 	/* TODO: Should really use a PurpleCircBuffer for this. */
 	GByteArray *buffer;
 
-	gpointer thumbnail_data;		/**< thumbnail image */
+	gpointer thumbnail_data;     /**< thumbnail image */
 	gsize thumbnail_size;
 	gchar *thumbnail_mimetype;
-} PurpleXferPrivData;
+};
 
 static int purple_xfer_choose_file(PurpleXfer *xfer);
 
 static void
 purple_xfer_priv_data_destroy(gpointer data)
 {
-	PurpleXferPrivData *priv = data;
+	PurpleXferPrivate *priv = data;
 
 	if (priv->buffer)
 		g_byte_array_free(priv->buffer, TRUE);
@@ -84,10 +129,10 @@ purple_xfer_priv_data_destroy(gpointer d
 }
 
 static const gchar *
-purple_xfer_status_type_to_string(PurpleXferStatusType type)
+purple_xfer_status_type_to_string(PurpleXferStatus type)
 {
 	static const struct {
-		PurpleXferStatusType type;
+		PurpleXferStatus type;
 		const char *name;
 	} type_names[] = {
 		{ PURPLE_XFER_STATUS_UNKNOWN, "unknown" },
@@ -118,7 +163,7 @@ purple_xfer_new(PurpleAccount *account, 
 {



More information about the Commits mailing list