/soc/2013/ankitkv/gobjectification: 5ecb9a6c4611: Added protocol...
Ankit Vani
a at nevitus.org
Mon Aug 19 12:06:44 EDT 2013
Changeset: 5ecb9a6c461150a334fbb3949f6d846655fdcee9
Author: Ankit Vani <a at nevitus.org>
Date: 2013-08-19 21:36 +0530
Branch: soc.2013.gobjectification.plugins
URL: https://hg.pidgin.im/soc/2013/ankitkv/gobjectification/rev/5ecb9a6c4611
Description:
Added protocol.[ch] and moved PurpleProtocol and PurpleProtocolInterface to it
diffstat:
libpurple/Makefile.am | 6 +-
libpurple/protocol.c | 25 ++
libpurple/protocol.h | 502 +++++++++++++++++++++++++++++++++++++++++++++
libpurple/protocols.h | 554 +++----------------------------------------------
libpurple/purple.h.in | 2 +-
5 files changed, 570 insertions(+), 519 deletions(-)
diffs (truncated from 1197 to 300 lines):
diff --git a/libpurple/Makefile.am b/libpurple/Makefile.am
--- a/libpurple/Makefile.am
+++ b/libpurple/Makefile.am
@@ -82,6 +82,7 @@ purple_coresources = \
presence.c \
proxy.c \
protocol.c \
+ protocols.c \
request.c \
roomlist.c \
savedstatuses.c \
@@ -153,6 +154,7 @@ purple_coreheaders = \
presence.h \
proxy.h \
protocol.h \
+ protocols.h \
request.h \
roomlist.h \
savedstatuses.h \
@@ -190,7 +192,7 @@ purple_enumheaders = \
connection.h \
conversation.h \
conversationtypes.h \
- protocol.h \
+ protocols.h \
status.h
marshallers.h: marshallers.list
@@ -232,7 +234,7 @@ dbus_exported = dbus-useful.h dbus-defin
blistnodetypes.h buddylist.h buddyicon.h connection.h conversation.h \
conversationtypes.h conversations.h core.h ft.h log.h notify.h \
prefs.h presence.h roomlist.h savedstatuses.h smiley.h status.h \
- server.h util.h xmlnode.h protocol.h
+ server.h util.h xmlnode.h protocol.h protocols.h
purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \
$(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
diff --git a/libpurple/protocol.c b/libpurple/protocol.c
new file mode 100644
--- /dev/null
+++ b/libpurple/protocol.c
@@ -0,0 +1,25 @@
+/*
+ * purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ *
+ */
+#include "internal.h"
+#include "protocol.h"
+
diff --git a/libpurple/protocol.h b/libpurple/protocol.h
new file mode 100644
--- /dev/null
+++ b/libpurple/protocol.h
@@ -0,0 +1,502 @@
+/**
+ * @file protocol.h PurpleProtocol and PurpleProtocolInterface API
+ * @ingroup core
+ */
+
+/* purple
+ *
+ * Purple is the legal property of its developers, whose names are too numerous
+ * to list here. Please refer to the COPYRIGHT file distributed with this
+ * source distribution.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
+ */
+
+#ifndef _PURPLE_PROTOCOL_H_
+#define _PURPLE_PROTOCOL_H_
+
+#define PURPLE_TYPE_PROTOCOL (purple_protocol_get_type())
+#define PURPLE_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocol))
+#define PURPLE_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
+#define PURPLE_IS_PROTOCOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), PURPLE_TYPE_PROTOCOL))
+#define PURPLE_IS_PROTOCOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), PURPLE_TYPE_PROTOCOL))
+#define PURPLE_PROTOCOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocolClass))
+#define PURPLE_PROTOCOL_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), PURPLE_TYPE_PROTOCOL, PurpleProtocolInterface))
+
+/** @copydoc _PurpleProtocol */
+typedef struct _PurpleProtocol PurpleProtocol;
+/** @copydoc _PurpleProtocolClass */
+typedef struct _PurpleProtocolClass PurpleProtocolClass;
+
+/** @copydoc _PurpleProtocolInterface */
+typedef struct _PurpleProtocolInterface PurpleProtocolInterface;
+
+/**
+ * Represents an instance of a protocol registered with the protocols
+ * subsystem.
+ */
+struct _PurpleProtocol
+{
+ /*< private >*/
+ GObject gparent;
+};
+
+/**
+ * The base class for all protocols.
+ *
+ * Protocols must set the members of this class to appropriate values upon
+ * class initialization.
+ */
+struct _PurpleProtocolClass
+{
+ /*< private >*/
+ GObjectClass parent_class;
+
+ const char *id; /**< Protocol ID */
+ const char *name; /**< Translated name of the protocol */
+
+ PurpleProtocolOptions options; /**< Protocol options */
+
+ GList *user_splits; /**< A GList of PurpleAccountUserSplit */
+ GList *protocol_options; /**< A GList of PurpleAccountOption */
+
+ PurpleBuddyIconSpec icon_spec; /**< The icon spec. */
+
+ void (*_purple_reserved1)(void);
+ void (*_purple_reserved2)(void);
+ void (*_purple_reserved3)(void);
+ void (*_purple_reserved4)(void);
+};
+
+/**
+ * The protocol interface.
+ *
+ * Every protocol implements this interface. It is the gateway between purple
+ * and the protocol's functions. Many of these callbacks can be NULL. If a
+ * callback must be implemented, it has a comment indicating so.
+ */
+struct _PurpleProtocolInterface
+{
+ /*< private >*/
+ GTypeInterface parent_iface;
+
+ /**
+ * Returns the actions the protocol can perform. These will show up in the
+ * Accounts menu, under a submenu with the name of the account.
+ */
+ GList *(*get_actions)(PurpleConnection *);
+
+ /**
+ * Returns the base icon name for the given buddy and account.
+ * If buddy is NULL and the account is non-NULL, it will return the
+ * name to use for the account's icon. If both are NULL, it will
+ * return the name to use for the protocol's icon.
+ *
+ * This must be implemented.
+ */
+ const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy);
+
+ /**
+ * Fills the four char**'s with string identifiers for "emblems"
+ * that the UI will interpret and display as relevant
+ */
+ const char *(*list_emblem)(PurpleBuddy *buddy);
+
+ /**
+ * Gets a short string representing this buddy's status. This will
+ * be shown on the buddy list.
+ */
+ char *(*status_text)(PurpleBuddy *buddy);
+
+ /**
+ * Allows the protocol to add text to a buddy's tooltip.
+ */
+ void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full);
+
+ /**
+ * Returns a list of #PurpleStatusType which exist for this account;
+ * this must be implemented, and must add at least the offline and
+ * online states.
+ */
+ GList *(*status_types)(PurpleAccount *account);
+
+ /**
+ * Returns a list of #PurpleMenuAction structs, which represent extra
+ * actions to be shown in (for example) the right-click menu for @a
+ * node.
+ */
+ GList *(*blist_node_menu)(PurpleBlistNode *node);
+
+ /**
+ * Returns a list of #PurpleProtocolChatEntry structs, which represent
+ * information required by the protocol to join a chat. libpurple will
+ * call join_chat along with the information filled by the user.
+ *
+ * @return A list of #PurpleProtocolChatEntry structs
+ */
+ GList *(*chat_info)(PurpleConnection *);
+
+ /**
+ * Returns a hashtable which maps #PurpleProtocolChatEntry struct
+ * identifiers to default options as strings based on chat_name. The
+ * resulting hashtable should be created with
+ * g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);. Use
+ * #get_chat_name if you instead need to extract a chat name from a
+ * hashtable.
+ *
+ * @param chat_name The chat name to be turned into components
+ * @return Hashtable containing the information extracted from chat_name
+ */
+ GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name);
+
+ /* All the server-related functions */
+
+ /** This must be implemented. */
+ void (*login)(PurpleAccount *);
+
+ /** This must be implemented. */
+ void (*close)(PurpleConnection *);
+
+ /**
+ * This protocol function should return a positive value on success.
+ * If the message is too big to be sent, return -E2BIG. If
+ * the account is not connected, return -ENOTCONN. If the
+ * protocol is unable to send the message for another reason, return
+ * some other negative value. You can use one of the valid
+ * errno values, or just big something. If the message should
+ * not be echoed to the conversation window, return 0.
+ */
+ int (*send_im)(PurpleConnection *, const char *who,
+ const char *message,
+ PurpleMessageFlags flags);
+
+ void (*set_info)(PurpleConnection *, const char *info);
+
+ /**
+ * @return If this protocol requires the PURPLE_IM_TYPING message to
+ * be sent repeatedly to signify that the user is still
+ * typing, then the protocol should return the number of
+ * seconds to wait before sending a subsequent notification.
+ * Otherwise the protocol should return 0.
+ */
+ unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleIMTypingState state);
+
+ /**
+ * Should arrange for purple_notify_userinfo() to be called with
+ * @a who's user info.
+ */
+ void (*get_info)(PurpleConnection *, const char *who);
+ void (*set_status)(PurpleAccount *account, PurpleStatus *status);
+
+ void (*set_idle)(PurpleConnection *, int idletime);
+ void (*change_passwd)(PurpleConnection *, const char *old_pass,
+ const char *new_pass);
+
+ /**
+ * Add a buddy to a group on the server.
+ *
+ * This protocol function may be called in situations in which the buddy is
+ * already in the specified group. If the protocol supports
+ * authorization and the user is not already authorized to see the
+ * status of \a buddy, \a add_buddy should request authorization.
+ *
+ * If authorization is required, then use the supplied invite message.
+ */
+ void (*add_buddy)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message);
+ void (*add_buddies)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message);
+ void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group);
+ void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups);
+ void (*add_permit)(PurpleConnection *, const char *name);
+ void (*add_deny)(PurpleConnection *, const char *name);
+ void (*rem_permit)(PurpleConnection *, const char *name);
+ void (*rem_deny)(PurpleConnection *, const char *name);
+ void (*set_permit_deny)(PurpleConnection *);
+
+ /**
+ * Called when the user requests joining a chat. Should arrange for
More information about the Commits
mailing list