diff options
author | Eion Robb <eion@robbmob.com> | 2015-06-08 00:29:54 +0300 |
---|---|---|
committer | Eion Robb <eion@robbmob.com> | 2015-06-08 00:29:54 +0300 |
commit | 6dfe530baf9f53cb69c93820437a4850f4c115d4 (patch) | |
tree | e1a1e16d182380820f4329f68dacc242a99a4065 /skypeweb | |
parent | 2638847239df3d670e6369fad3ffca069bae1c9e (diff) |
SkypeWeb : Start converting things over to purple3 with #defines to make it compile for purple2
Diffstat (limited to 'skypeweb')
-rw-r--r-- | skypeweb/libskypeweb.c | 85 | ||||
-rw-r--r-- | skypeweb/libskypeweb.h | 81 | ||||
-rw-r--r-- | skypeweb/skypeweb_connection.c | 12 | ||||
-rw-r--r-- | skypeweb/skypeweb_contacts.c | 6 | ||||
-rw-r--r-- | skypeweb/skypeweb_login.c | 4 | ||||
-rw-r--r-- | skypeweb/skypeweb_messages.c | 197 | ||||
-rw-r--r-- | skypeweb/skypeweb_messages.h | 4 | ||||
-rw-r--r-- | skypeweb/skypeweb_util.c | 22 |
8 files changed, 251 insertions, 160 deletions
diff --git a/skypeweb/libskypeweb.c b/skypeweb/libskypeweb.c index 4fc7642..eba639c 100644 --- a/skypeweb/libskypeweb.c +++ b/skypeweb/libskypeweb.c @@ -60,7 +60,7 @@ skypeweb_list_icon(PurpleAccount *account, PurpleBuddy *buddy) static gchar *
skypeweb_status_text(PurpleBuddy *buddy)
{
- SkypeWebBuddy *sbuddy = buddy->proto_data;
+ SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
if (sbuddy && sbuddy->mood && *(sbuddy->mood))
{
@@ -73,13 +73,13 @@ skypeweb_status_text(PurpleBuddy *buddy) void
skypeweb_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full)
{
- SkypeWebBuddy *sbuddy = buddy->proto_data;
+ SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
if (sbuddy)
{
PurplePresence *presence;
PurpleStatus *status;
- SkypeWebBuddy *sbuddy = buddy->proto_data;
+ SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
presence = purple_buddy_get_presence(buddy);
status = purple_presence_get_active_status(presence);
@@ -97,7 +97,7 @@ skypeweb_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gbool const gchar *
skypeweb_list_emblem(PurpleBuddy *buddy)
{
- //SkypeWebBuddy *sbuddy = buddy->proto_data;
+ //SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
return NULL;
}
@@ -132,15 +132,15 @@ static GList * skypeweb_chat_info(PurpleConnection *gc)
{
GList *m = NULL;
- struct proto_chat_entry *pce;
+ PurpleProtocolChatEntry *pce;
- pce = g_new0(struct proto_chat_entry, 1);
+ pce = g_new0(PurpleProtocolChatEntry, 1);
pce->label = _("Skype Name");
pce->identifier = "chatname";
pce->required = TRUE;
m = g_list_append(m, pce);
- /*pce = g_new0(struct proto_chat_entry, 1);
+ /*pce = g_new0(PurpleProtocolChatEntry, 1);
pce->label = _("Password");
pce->identifier = "password";
pce->required = FALSE;
@@ -181,11 +181,11 @@ skypeweb_get_chat_name(GHashTable *data) static void
skypeweb_join_chat(PurpleConnection *pc, GHashTable *data)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
gchar *chatname;
gchar *post;
GString *url;
- PurpleConversation *conv;
+ PurpleChatConversation *chatconv;
chatname = (gchar *)g_hash_table_lookup(data, "chatname");
if (chatname == NULL)
@@ -193,9 +193,9 @@ skypeweb_join_chat(PurpleConnection *pc, GHashTable *data) return;
}
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chatname, sa->account);
- if (conv != NULL) {
- purple_conversation_present(conv);
+ chatconv = purple_conversations_find_chat_with_account(chatname, sa->account);
+ if (chatconv != NULL) {
+ purple_conversation_present(PURPLE_CONVERSATION(chatconv));
return;
}
@@ -213,19 +213,19 @@ skypeweb_join_chat(PurpleConnection *pc, GHashTable *data) skypeweb_get_conversation_history(sa, chatname);
skypeweb_get_thread_users(sa, chatname);
- conv = serv_got_joined_chat(pc, g_str_hash(chatname), chatname);
- purple_conversation_set_data(conv, "chatname", g_strdup(chatname));
+ chatconv = purple_serv_got_joined_chat(pc, g_str_hash(chatname), chatname);
+ purple_conversation_set_data(PURPLE_CONVERSATION(chatconv), "chatname", g_strdup(chatname));
- purple_conversation_present(conv);
+ purple_conversation_present(PURPLE_CONVERSATION(chatconv));
}
static void
skypeweb_buddy_free(PurpleBuddy *buddy)
{
- SkypeWebBuddy *sbuddy = buddy->proto_data;
+ SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
if (sbuddy != NULL)
{
- buddy->proto_data = NULL;
+ purple_buddy_set_protocol_data(buddy, NULL);
g_free(sbuddy->skypename);
g_free(sbuddy->fullname);
@@ -256,15 +256,15 @@ skypeweb_node_menu(PurpleBlistNode *node) PurpleBuddy *buddy;
SkypeWebAccount *sa = NULL;
- if(PURPLE_BLIST_NODE_IS_BUDDY(node))
+ if(PURPLE_IS_BUDDY(node))
{
buddy = (PurpleBuddy *)node;
- if (buddy->proto_data) {
- SkypeWebBuddy *sbuddy = (SkypeWebBuddy *)buddy->proto_data;
+ if (purple_buddy_get_protocol_data(buddy)) {
+ SkypeWebBuddy *sbuddy = purple_buddy_get_protocol_data(buddy);
sa = sbuddy->sa;
} else {
- PurpleConnection *pc = purple_account_get_connection(buddy->account);
- sa = pc->proto_data;
+ PurpleConnection *pc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ sa = purple_connection_get_protocol_data(pc);
}
if (sa != NULL) {
@@ -284,7 +284,7 @@ skypeweb_login(PurpleAccount *account) PurpleConnection *pc = purple_account_get_connection(account);
SkypeWebAccount *sa = g_new0(SkypeWebAccount, 1);
- pc->proto_data = sa;
+ purple_connection_set_protocol_data(pc, sa);
if (!purple_ssl_is_supported()) {
purple_connection_error (pc,
@@ -295,7 +295,7 @@ skypeweb_login(PurpleAccount *account) pc->flags |= PURPLE_CONNECTION_HTML | PURPLE_CONNECTION_NO_BGCOLOR | PURPLE_CONNECTION_NO_FONTSIZE;
- sa->username = g_strdup(account->username);
+ sa->username = g_strdup(purple_account_get_username(account));
sa->account = account;
sa->pc = pc;
sa->cookie_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
@@ -320,9 +320,9 @@ skypeweb_close(PurpleConnection *pc) SkypeWebAccount *sa;
g_return_if_fail(pc != NULL);
- g_return_if_fail(pc->proto_data != NULL);
- sa = pc->proto_data;
+ sa = purple_connection_get_protocol_data(pc);
+ g_return_if_fail(sa != NULL);
purple_timeout_remove(sa->authcheck_timeout);
purple_timeout_remove(sa->poll_timeout);
@@ -384,13 +384,16 @@ skypeweb_cmd_leave(PurpleConversation *conv, const gchar *cmd, gchar **args, gch int id = -1;
SkypeWebAccount *sa;
- pc = purple_conversation_get_gc(conv);
- id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));
+ pc = purple_conversation_get_connection(conv);
+ id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv));
- if (pc == NULL || id == -1 || pc->proto_data == NULL)
+ if (pc == NULL || id == -1)
+ return PURPLE_CMD_RET_FAILED;
+
+ sa = purple_connection_get_protocol_data(pc);
+ if (sa == NULL)
return PURPLE_CMD_RET_FAILED;
- sa = pc->proto_data;
skypeweb_chat_kick(pc, id, sa->username);
return PURPLE_CMD_RET_OK;
@@ -402,8 +405,8 @@ skypeweb_cmd_kick(PurpleConversation *conv, const gchar *cmd, gchar **args, gcha PurpleConnection *pc = NULL;
int id = -1;
- pc = purple_conversation_get_gc(conv);
- id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));
+ pc = purple_conversation_get_connection(conv);
+ id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv));
if (pc == NULL || id == -1)
return PURPLE_CMD_RET_FAILED;
@@ -419,8 +422,8 @@ skypeweb_cmd_invite(PurpleConversation *conv, const gchar *cmd, gchar **args, gc PurpleConnection *pc = NULL;
int id = -1;
- pc = purple_conversation_get_gc(conv);
- id = purple_conv_chat_get_id(PURPLE_CONV_CHAT(conv));
+ pc = purple_conversation_get_connection(conv);
+ id = purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv));
if (pc == NULL || id == -1)
return PURPLE_CMD_RET_FAILED;
@@ -466,16 +469,16 @@ skypeweb_uri_handler(const char *proto, const char *cmd, GHashTable *params) //there'll be a bunch of usernames, seperated by semi-colon
if (strchr(cmd, ';')) {
gchar **users = g_strsplit_set(cmd, ";", -1);
- skypeweb_initiate_chat(pc->proto_data, users[0]);
+ skypeweb_initiate_chat(purple_connection_get_protocol_data(pc), users[0]);
//TODO the other users
g_strfreev(users);
} else {
- PurpleConversation *conv;
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, cmd, account);
- if (!conv) {
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, cmd);
+ PurpleIMConversation *imconv;
+ imconv = purple_conversations_find_im_with_account(cmd, account);
+ if (!imconv) {
+ imconv = purple_im_conversation_new(account, cmd);
}
- purple_conversation_present(conv);
+ purple_conversation_present(PURPLE_CONVERSATION(imconv));
}
} else {
//probably a public multi-user chat?
@@ -514,6 +517,8 @@ skypeweb_uri_handler(const char *proto, const char *cmd, GHashTable *params) static gboolean
plugin_load(PurplePlugin *plugin)
{
+ purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", plugin, PURPLE_CALLBACK(skypeweb_mark_conv_seen), NULL);
+
return TRUE;
}
diff --git a/skypeweb/libskypeweb.h b/skypeweb/libskypeweb.h index 778add0..ef76083 100644 --- a/skypeweb/libskypeweb.h +++ b/skypeweb/libskypeweb.h @@ -61,14 +61,12 @@ #endif #include "accountopt.h" -#include "blist.h" #include "core.h" #include "cmds.h" #include "connection.h" #include "debug.h" #include "dnsquery.h" #include "proxy.h" -#include "prpl.h" #include "request.h" #include "roomlist.h" #include "savedstatuses.h" @@ -76,6 +74,14 @@ #include "util.h" #include "version.h" +#if !PURPLE_VERSION_CHECK(3, 0, 0) + #include "blist.h" + #include "prpl.h" +#else + #include "buddylist.h" + #include "plugins.h" +#endif + #if GLIB_MAJOR_VERSION >= 2 && GLIB_MINOR_VERSION >= 12 # define atoll(a) g_ascii_strtoll(a, NULL, 0) #endif @@ -84,6 +90,77 @@ #define purple_connection_error purple_connection_error_reason #define purple_notify_user_info_add_pair_html purple_notify_user_info_add_pair #define purple_util_fetch_url_request purple_util_fetch_url_request_len_with_account + + #define PurpleConversationUpdateType PurpleConvUpdateType + #define PurpleChatConversation PurpleConvChat + #define PurpleIMConversation PurpleConvIm + #define PurpleProtocolAction PurplePluginAction +/* #define G_TYPE_STRING PURPLE_TYPE_STRING */ + #define PURPLE_IS_BUDDY PURPLE_BLIST_NODE_IS_BUDDY + #define PurpleProtocolChatEntry struct proto_chat_entry + #define PURPLE_CONNECTION_CONNECTED PURPLE_CONNECTED + #define PURPLE_CONNECTION_CONNECTING PURPLE_CONNECTING + #define purple_connection_get_protocol_data(pc) ((pc)->proto_data) + #define purple_connection_set_protocol_data(pc, data) ((pc)->proto_data = (data)) + #define purple_conversation_present_error purple_conv_present_error + #define purple_account_privacy_check purple_privacy_check + #define purple_serv_got_im serv_got_im + #define purple_serv_got_typing serv_got_typing + #define PurpleIMTypingState PurpleTypingState + #define PURPLE_IM_NOT_TYPING PURPLE_NOT_TYPING + #define PURPLE_IM_TYPING PURPLE_TYPING + #define PURPLE_IM_TYPED PURPLE_TYPED + #define purple_blist_find_buddy purple_find_buddy + #define purple_blist_find_group purple_find_group + #define PurpleChatUser PurpleConvChatBuddy + #define PurpleChatUserFlags PurpleConvChatBuddyFlags + #define PURPLE_CHAT_USER_NONE PURPLE_CBFLAGS_NONE + #define PURPLE_CHAT_USER_OP PURPLE_CBFLAGS_OP + #define PURPLE_CHAT_USER_VOICE PURPLE_CBFLAGS_VOICE + #define purple_chat_user_set_flags(cb, flags) purple_conv_chat_user_set_flags(cb->chat, cb->name, flags) + #define purple_serv_got_joined_chat serv_got_joined_chat + #define purple_serv_got_chat_invite serv_got_chat_invite + #define purple_serv_got_chat_in serv_got_chat_in + #define purple_chat_conversation_set_topic purple_conv_chat_set_topic + #define purple_chat_conversation_find_user purple_conv_chat_find_user + #define purple_chat_conversation_add_user purple_conv_chat_add_user + #define purple_chat_conversation_leave purple_conv_chat_left + #define purple_chat_conversation_add_user purple_conv_chat_add_user + #define purple_chat_conversation_remove_user purple_conv_chat_remove_user + #define purple_chat_conversation_clear_users purple_conv_chat_clear_users + #define purple_protocol_got_user_status purple_prpl_got_user_status + #define purple_protocol_got_user_idle purple_prpl_got_user_idle + #define PURPLE_CONVERSATION_UPDATE_TOPIC PURPLE_CONV_UPDATE_TOPIC + #define PURPLE_CONVERSATION_UPDATE_UNSEEN PURPLE_CONV_UPDATE_UNSEEN + #define purple_conversations_find_chat purple_find_chat + #define purple_conversations_find_chat_with_account(name, account) PURPLE_CONV_CHAT(purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, name, account)) + #define purple_conversations_find_im_with_account(name, account) PURPLE_CONV_IM(purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, account)) + #define purple_chat_conversation_new(account, from) PURPLE_CONV_CHAT(purple_conversation_new(PURPLE_CONV_TYPE_CHAT, account, from)) + #define purple_im_conversation_new(account, from) PURPLE_CONV_IM(purple_conversation_new(PURPLE_CONV_TYPE_IM, account, from)) + #define PURPLE_CONVERSATION(chatorim) (chatorim->conv) + #define PURPLE_IM_CONVERSATION(conv) PURPLE_CONV_IM(conv) + #define PURPLE_CHAT_CONVERSATION(conv) PURPLE_CONV_CHAT(conv) + #define PURPLE_IS_IM_CONVERSATION(conv) (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) + #define PURPLE_IS_CHAT_CONVERSATION(conv) (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_CHAT) + #define purple_conversation_get_connection purple_conversation_get_gc + #define PurpleMessage PurpleConvMessage + #define purple_conversation_write_message(conv, msg) purple_conversation_write(conv, msg->who, msg->what, msg->flags, msg->when) + #define PurpleXmlNode xmlnode + #define purple_xmlnode_from_str xmlnode_from_str + #define purple_xmlnode_get_child xmlnode_get_child + #define purple_xmlnode_get_next_twin xmlnode_get_next_twin + #define purple_xmlnode_get_data xmlnode_get_data + #define purple_xmlnode_get_attrib xmlnode_get_attrib + #define purple_xmlnode_free xmlnode_free + #define PurpleHash PurpleCipherContext + #define purple_sha256_hash_new() purple_cipher_context_new(purple_ciphers_find_cipher("sha256"), NULL) + #define purple_hash_append purple_cipher_context_append + #define purple_hash_digest(hash, data, len) purple_cipher_context_digest(hash, len, data, NULL) + #define purple_hash_destroy purple_cipher_context_destroy +#else + #define purple_conversation_set_data(conv, key, value) g_object_set_data(G_OBJECT(conv), key, value) + #define purple_conversation_get_data(conv, key) g_object_get_data(G_OBJECT(conv), key) + #define purple_hash_destroy g_object_unref #endif #define SKYPEWEB_MAX_MSG_RETRY 2 diff --git a/skypeweb/skypeweb_connection.c b/skypeweb/skypeweb_connection.c index ffc463d..05a664c 100644 --- a/skypeweb/skypeweb_connection.c +++ b/skypeweb/skypeweb_connection.c @@ -20,6 +20,8 @@ #if !PURPLE_VERSION_CHECK(3, 0, 0) #define purple_connection_error purple_connection_error_reason + #define purple_proxy_info_get_proxy_type purple_proxy_info_get_type + #define purple_account_is_disconnecting(account) (account->disconnecting) #endif #if !GLIB_CHECK_VERSION (2, 22, 0) @@ -543,9 +545,9 @@ skypeweb_post_or_get(SkypeWebAccount *sa, SkypeWebMethod method, if (sa && sa->account && !(method & SKYPEWEB_METHOD_SSL)) { proxy_info = purple_proxy_get_setup(sa->account); - if (purple_proxy_info_get_type(proxy_info) == PURPLE_PROXY_USE_GLOBAL) + if (purple_proxy_info_get_proxy_type(proxy_info) == PURPLE_PROXY_USE_GLOBAL) proxy_info = purple_global_proxy_get_info(); - if (purple_proxy_info_get_type(proxy_info) == PURPLE_PROXY_HTTP) + if (purple_proxy_info_get_proxy_type(proxy_info) == PURPLE_PROXY_HTTP) { is_proxy = TRUE; } @@ -701,9 +703,9 @@ static void skypeweb_attempt_connection(SkypeWebConnection *skypewebcon) if (sa && sa->account && !(skypewebcon->method & SKYPEWEB_METHOD_SSL)) { proxy_info = purple_proxy_get_setup(sa->account); - if (purple_proxy_info_get_type(proxy_info) == PURPLE_PROXY_USE_GLOBAL) + if (purple_proxy_info_get_proxy_type(proxy_info) == PURPLE_PROXY_USE_GLOBAL) proxy_info = purple_global_proxy_get_info(); - if (purple_proxy_info_get_type(proxy_info) == PURPLE_PROXY_HTTP) + if (purple_proxy_info_get_proxy_type(proxy_info) == PURPLE_PROXY_HTTP) { is_proxy = TRUE; } @@ -753,7 +755,7 @@ static void skypeweb_attempt_connection(SkypeWebConnection *skypewebcon) if (host_ip != NULL) { g_free(skypewebcon->hostname); skypewebcon->hostname = g_strdup(host_ip); - } else if (sa->account && !sa->account->disconnecting) { + } else if (sa->account && !purple_account_is_disconnecting(sa->account)) { GSList *host_lookup_list = NULL; PurpleDnsQueryData *query; diff --git a/skypeweb/skypeweb_contacts.c b/skypeweb/skypeweb_contacts.c index d355d57..034b7ac 100644 --- a/skypeweb/skypeweb_contacts.c +++ b/skypeweb/skypeweb_contacts.c @@ -22,7 +22,11 @@ #include "skypeweb_messages.h"
#include "skypeweb_util.h"
-#include <ft.h>
+#if !PURPLE_VERSION_CHECK(3, 0, 0)
+# include "ft.h"
+#else
+# include "xfer.h"
+#endif
static guint active_icon_downloads = 0;
diff --git a/skypeweb/skypeweb_login.c b/skypeweb/skypeweb_login.c index 7188ebf..690efa7 100644 --- a/skypeweb/skypeweb_login.c +++ b/skypeweb/skypeweb_login.c @@ -123,7 +123,7 @@ skypeweb_begin_web_login(SkypeWebAccount *sa) purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, NULL, FALSE, 524288, skypeweb_login_got_pie, sa);
- purple_connection_set_state(sa->pc, PURPLE_CONNECTING);
+ purple_connection_set_state(sa->pc, PURPLE_CONNECTION_CONNECTING);
purple_connection_update_progress(sa->pc, _("Connecting"), 1, 4);
}
@@ -238,7 +238,7 @@ skypeweb_begin_oauth_login(SkypeWebAccount *sa) purple_util_fetch_url_request(sa->account, login_url, TRUE, NULL, FALSE, NULL, TRUE, 524288, skypeweb_login_got_ppft, sa);
- purple_connection_set_state(sa->pc, PURPLE_CONNECTING);
+ purple_connection_set_state(sa->pc, PURPLE_CONNECTION_CONNECTING);
purple_connection_update_progress(sa->pc, _("Connecting"), 1, 4);
}
diff --git a/skypeweb/skypeweb_messages.c b/skypeweb/skypeweb_messages.c index b582c36..5e173e3 100644 --- a/skypeweb/skypeweb_messages.c +++ b/skypeweb/skypeweb_messages.c @@ -46,9 +46,9 @@ process_userpresence_resource(SkypeWebAccount *sa, JsonObject *resource) g_return_if_fail(from);
//TODO not need me
- if (!purple_find_buddy(sa->account, from))
+ if (!purple_blist_find_buddy(sa->account, from))
{
- PurpleGroup *group = purple_find_group("Skype");
+ PurpleGroup *group = purple_blist_find_group("Skype");
if (!group)
{
group = purple_group_new("Skype");
@@ -57,8 +57,8 @@ process_userpresence_resource(SkypeWebAccount *sa, JsonObject *resource) purple_blist_add_buddy(purple_buddy_new(sa->account, from, NULL), NULL, group, NULL);
}
- purple_prpl_got_user_status(sa->account, from, status, NULL);
- purple_prpl_got_user_idle(sa->account, from, g_str_equal(status, "Idle"), 0);
+ purple_protocol_got_user_status(sa->account, from, status, NULL);
+ purple_protocol_got_user_idle(sa->account, from, g_str_equal(status, "Idle"), 0);
}
static void
@@ -73,7 +73,7 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) const gchar *conversationLink = json_object_get_string_member(resource, "conversationLink");
time_t composetimestamp = purple_str_to_time(composetime, TRUE, NULL, NULL, NULL);
gchar **messagetype_parts;
- PurpleConversation *conv = NULL;
+ //PurpleConversation *conv = NULL;
gchar *convname = NULL;
messagetype_parts = g_strsplit(messagetype, "/", -1);
@@ -98,20 +98,22 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) if (strstr(conversationLink, "/19:")) {
// This is a Thread/Group chat message
const gchar *chatname, *topic;
+ PurpleChatConversation *chatconv;
chatname = skypeweb_thread_url_to_name(conversationLink);
convname = g_strdup(chatname);
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chatname, sa->account);
- if (!conv) {
- conv = serv_got_joined_chat(sa->pc, g_str_hash(chatname), chatname);
- purple_conversation_set_data(conv, "chatname", g_strdup(chatname));
+ chatconv = purple_conversations_find_chat_with_account(chatname, sa->account);
+ if (!chatconv) {
+ chatconv = purple_serv_got_joined_chat(sa->pc, g_str_hash(chatname), chatname);
+ purple_conversation_set_data(PURPLE_CONVERSATION(chatconv), "chatname", g_strdup(chatname));
topic = json_object_get_string_member(resource, "threadtopic");
- purple_conv_chat_set_topic(PURPLE_CONV_CHAT(conv), NULL, topic);
+ purple_chat_conversation_set_topic(chatconv, NULL, topic);
skypeweb_get_conversation_history(sa, chatname);
skypeweb_get_thread_users(sa, chatname);
}
+ conv = PURPLE_CONVERSATION(chatconv);
if ((g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text")) && content && *content) {
gchar *html;
@@ -129,69 +131,69 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) } else {
html = skypeweb_meify(content, skypeemoteoffset);
}
- serv_got_chat_in(sa->pc, g_str_hash(chatname), from, g_str_equal(sa->username, from) ? PURPLE_MESSAGE_SEND : PURPLE_MESSAGE_RECV, html, composetimestamp);
+ purple_serv_got_chat_in(sa->pc, g_str_hash(chatname), from, g_str_equal(sa->username, from) ? PURPLE_MESSAGE_SEND : PURPLE_MESSAGE_RECV, html, composetimestamp);
g_free(html);
} else if (g_str_equal(messagetype, "ThreadActivity/AddMember")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- xmlnode *target;
- for(target = xmlnode_get_child(blob, "target"); target;
- target = xmlnode_get_next_twin(target))
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ PurpleXmlNode *target;
+ for(target = purple_xmlnode_get_child(blob, "target"); target;
+ target = purple_xmlnode_get_next_twin(target))
{
- gchar *user = xmlnode_get_data(target);
- if (!purple_conv_chat_find_user(PURPLE_CONV_CHAT(conv), &user[2]))
- purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), &user[2], NULL, PURPLE_CBFLAGS_NONE, TRUE);
+ gchar *user = purple_xmlnode_get_data(target);
+ if (!purple_chat_conversation_find_user(chatconv, &user[2]))
+ purple_chat_conversation_add_user(chatconv, &user[2], NULL, PURPLE_CHAT_USER_NONE, TRUE);
g_free(user);
}
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else if (g_str_equal(messagetype, "ThreadActivity/DeleteMember")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- xmlnode *target;
- for(target = xmlnode_get_child(blob, "target"); target;
- target = xmlnode_get_next_twin(target))
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ PurpleXmlNode *target;
+ for(target = purple_xmlnode_get_child(blob, "target"); target;
+ target = purple_xmlnode_get_next_twin(target))
{
- gchar *user = xmlnode_get_data(target);
+ gchar *user = purple_xmlnode_get_data(target);
if (g_str_equal(sa->username, &user[2]))
- purple_conv_chat_left(PURPLE_CONV_CHAT(conv));
- purple_conv_chat_remove_user(PURPLE_CONV_CHAT(conv), &user[2], NULL);
+ purple_chat_conversation_leave(chatconv);
+ purple_chat_conversation_remove_user(chatconv, &user[2], NULL);
g_free(user);
}
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else if (g_str_equal(messagetype, "ThreadActivity/TopicUpdate")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- gchar *initiator = xmlnode_get_data(xmlnode_get_child(blob, "initiator"));
- gchar *value = xmlnode_get_data(xmlnode_get_child(blob, "value"));
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ gchar *initiator = purple_xmlnode_get_data(purple_xmlnode_get_child(blob, "initiator"));
+ gchar *value = purple_xmlnode_get_data(purple_xmlnode_get_child(blob, "value"));
- purple_conv_chat_set_topic(PURPLE_CONV_CHAT(conv), &initiator[2], value);
- purple_conversation_update(conv, PURPLE_CONV_UPDATE_TOPIC);
+ purple_chat_conversation_set_topic(chatconv, &initiator[2], value);
+ purple_conversation_update(conv, PURPLE_CONVERSATION_UPDATE_TOPIC);
g_free(initiator);
g_free(value);
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else if (g_str_equal(messagetype, "ThreadActivity/RoleUpdate")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- xmlnode *target;
- for(target = xmlnode_get_child(blob, "target"); target;
- target = xmlnode_get_next_twin(target))
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ PurpleXmlNode *target;
+ for(target = purple_xmlnode_get_child(blob, "target"); target;
+ target = purple_xmlnode_get_next_twin(target))
{
- gchar *user = xmlnode_get_data(xmlnode_get_child(target, "id"));
- gchar *role = xmlnode_get_data(xmlnode_get_child(target, "role"));
- PurpleConvChatBuddyFlags cbflags = PURPLE_CBFLAGS_NONE;
+ gchar *user = purple_xmlnode_get_data(purple_xmlnode_get_child(target, "id"));
+ gchar *role = purple_xmlnode_get_data(purple_xmlnode_get_child(target, "role"));
+ PurpleChatUserFlags cbflags = PURPLE_CHAT_USER_NONE;
if (role && *role) {
if (g_str_equal(role, "Admin")) {
- cbflags = PURPLE_CBFLAGS_OP;
+ cbflags = PURPLE_CHAT_USER_OP;
} else if (g_str_equal(role, "User")) {
- cbflags = PURPLE_CBFLAGS_VOICE;
+ cbflags = PURPLE_CHAT_USER_VOICE;
}
}
- purple_conv_chat_user_set_flags(PURPLE_CONV_CHAT(conv), &user[2], cbflags);
+ purple_chat_user_set_flags(chatconv, &user[2], cbflags);
g_free(user);
g_free(role);
}
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else {
purple_debug_warning("skypeweb", "Unhandled thread message resource messagetype '%s'\n", messagetype);
}
@@ -203,13 +205,14 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) if (g_str_equal(messagetype_parts[0], "Control")) {
if (g_str_equal(messagetype_parts[1], "ClearTyping")) {
- serv_got_typing(sa->pc, from, 7, PURPLE_NOT_TYPING);
+ purple_serv_got_typing(sa->pc, from, 7, PURPLE_IM_NOT_TYPING);
} else if (g_str_equal(messagetype_parts[1], "Typing")) {
- serv_got_typing(sa->pc, from, 7, PURPLE_TYPING);
+ purple_serv_got_typing(sa->pc, from, 7, PURPLE_IM_TYPING);
}
} else if ((g_str_equal(messagetype, "RichText") || g_str_equal(messagetype, "Text")) && content && *content) {
gchar *html;
gint64 skypeemoteoffset = 0;
+ PurpleIMConversation *imconv;
if (json_object_has_member(resource, "skypeemoteoffset"))
skypeemoteoffset = atoi(json_object_get_string_member(resource, "skypeemoteoffset"));
@@ -226,52 +229,52 @@ process_message_resource(SkypeWebAccount *sa, JsonObject *resource) if (g_str_equal(sa->username, from)) {
from = skypeweb_contact_url_to_name(conversationLink);
if (from != NULL && !g_str_has_prefix(html, "?OTR")) {
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, sa->account);
+ conv = purple_conversations_find_im_with_account(from, sa->account);
if (conv == NULL)
{
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, sa->account, from);
+ conv = purple_im_conversation_new(sa->account, from);
}
purple_conversation_write(conv, from, html, PURPLE_MESSAGE_SEND, composetimestamp);
}
} else {
- serv_got_im(sa->pc, from, html, PURPLE_MESSAGE_RECV, composetimestamp);
+ purple_serv_got_im(sa->pc, from, html, PURPLE_MESSAGE_RECV, composetimestamp);
}
g_free(html);
} else if (g_str_equal(messagetype, "RichText/UriObject")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- const gchar *uri = xmlnode_get_attrib(blob, "uri");
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ const gchar *uri = purple_xmlnode_get_attrib(blob, "uri");
if (g_str_equal(sa->username, from)) {
from = skypeweb_contact_url_to_name(conversationLink);
}
if (from != NULL) {
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, sa->account);
+ conv = purple_conversations_find_im_with_account(from, sa->account);
if (conv == NULL)
{
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, sa->account, from);
+ conv = purple_im_conversation_new(sa->account, from);
}
skypeweb_download_uri_to_conv(sa, uri, conv);
}
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else if (g_str_equal(messagetype, "Event/SkypeVideoMessage")) {
- xmlnode *blob = xmlnode_from_str(content, -1);
- const gchar *sid = xmlnode_get_attrib(blob, "sid");
+ PurpleXmlNode *blob = purple_xmlnode_from_str(content, -1);
+ const gchar *sid = purple_xmlnode_get_attrib(blob, "sid");
if (g_str_equal(sa->username, from)) {
from = skypeweb_contact_url_to_name(conversationLink);
}
if (from != NULL) {
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, from, sa->account);
+ conv = purple_conversations_find_im_with_account(from, sa->account);
if (conv == NULL)
{
- conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, sa->account, from);
+ conv = purple_im_conversation_new(sa->account, from);
}
//skypeweb_download_video_message(sa, sid, conv); //TODO
- serv_got_im(sa->pc, from, content, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, composetimestamp);
+ purple_serv_got_im(sa->pc, from, content, PURPLE_MESSAGE_RECV | PURPLE_MESSAGE_SYSTEM, composetimestamp);
}
- xmlnode_free(blob);
+ purple_xmlnode_free(blob);
} else {
purple_debug_warning("skypeweb", "Unhandled message resource messagetype '%s'\n", messagetype);
}
@@ -442,18 +445,18 @@ skypeweb_poll(SkypeWebAccount *sa) }
void
-skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConvUpdateType type)
+skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConversationUpdateType type)
{
- if (type == PURPLE_CONV_UPDATE_UNSEEN) {
+ if (type == PURPLE_CONVERSATION_UPDATE_UNSEEN) {
gchar *last_skypeweb_id = purple_conversation_get_data(conv, "last_skypeweb_id");
if (last_skypeweb_id && *last_skypeweb_id) {
PurpleAccount *account = purple_conversation_get_account(conv);
- SkypeWebAccount *sa = purple_account_get_connection(account)->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(purple_account_get_connection(account));
gchar *post, *url, *convname;
- if (purple_conversation_get_type(conv) == PURPLE_CONV_TYPE_IM) {
- convname = g_strconcat("8:", conv->name, NULL);
+ if (PURPLE_IS_IM_CONVERSATION(conv)) {
+ convname = g_strconcat("8:", purple_conversation_get_name(conv), NULL);
} else {
convname = g_strdup(purple_conversation_get_data(conv, "chatname"));
}
@@ -476,16 +479,16 @@ skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConvUpdateType type) static void
skypeweb_got_thread_users(SkypeWebAccount *sa, JsonNode *node, gpointer user_data)
{
- PurpleConversation *conv;
+ PurpleChatConversation *chatconv;
gchar *chatname = user_data;
JsonObject *response;
JsonArray *members;
gint length, index;
- conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_CHAT, chatname, sa->account);
- if (conv == NULL)
+ chatconv = purple_conversations_find_chat_with_account(chatname, sa->account);
+ if (chatconv == NULL)
return;
- purple_conv_chat_clear_users(PURPLE_CONV_CHAT(conv));
+ purple_chat_conversation_clear_users(chatconv);
if (node == NULL || json_node_get_node_type(node) != JSON_NODE_OBJECT)
return;
@@ -499,17 +502,17 @@ skypeweb_got_thread_users(SkypeWebAccount *sa, JsonNode *node, gpointer user_dat const gchar *userLink = json_object_get_string_member(member, "userLink");
const gchar *role = json_object_get_string_member(member, "role");
const gchar *username = skypeweb_contact_url_to_name(userLink);
- PurpleConvChatBuddyFlags cbflags = PURPLE_CBFLAGS_NONE;
+ PurpleChatUserFlags cbflags = PURPLE_CHAT_USER_NONE;
if (role && *role) {
if (g_str_equal(role, "Admin")) {
- cbflags = PURPLE_CBFLAGS_OP;
+ cbflags = PURPLE_CHAT_USER_OP;
} else if (g_str_equal(role, "User")) {
- cbflags = PURPLE_CBFLAGS_VOICE;
+ cbflags = PURPLE_CHAT_USER_VOICE;
}
}
- purple_conv_chat_add_user(PURPLE_CONV_CHAT(conv), username, NULL, cbflags, FALSE);
+ purple_chat_conversation_add_user(chatconv, username, NULL, cbflags, FALSE);
}
}
@@ -650,7 +653,7 @@ skypeweb_got_roomlist_threads(SkypeWebAccount *sa, JsonNode *node, gpointer user PurpleRoomlist *
skypeweb_roomlist_get_list(PurpleConnection *pc)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
const gchar *url = "/v1/users/ME/conversations?startTime=0&pageSize=100&view=msnp24Equivalent&targetType=Thread";
PurpleRoomlist *roomlist;
GList *fields = NULL;
@@ -859,9 +862,9 @@ skypeweb_get_registration_token(SkypeWebAccount *sa) guint
-skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleTypingState state)
+skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleIMTypingState state)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
gchar *post, *url;
JsonObject *obj;
@@ -870,7 +873,7 @@ skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleTypingState obj = json_object_new();
json_object_set_int_member(obj, "clientmessageid", time(NULL));
json_object_set_string_member(obj, "content", "");
- json_object_set_string_member(obj, "messagetype", state == PURPLE_TYPING ? "Control/Typing" : "Control/ClearTyping");
+ json_object_set_string_member(obj, "messagetype", state == PURPLE_IM_TYPING ? "Control/Typing" : "Control/ClearTyping");
json_object_set_string_member(obj, "contenttype", "text");
post = skypeweb_jsonobj_to_string(obj);
@@ -907,7 +910,7 @@ void skypeweb_set_status(PurpleAccount *account, PurpleStatus *status)
{
PurpleConnection *pc = purple_account_get_connection(account);
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
skypeweb_set_statusid(sa, purple_status_get_id(status));
}
@@ -915,7 +918,7 @@ skypeweb_set_status(PurpleAccount *account, PurpleStatus *status) void
skypeweb_set_idle(PurpleConnection *pc, int time)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
if (time < 30) {
skypeweb_set_statusid(sa, "Online");
@@ -968,19 +971,19 @@ skypeweb_send_message(SkypeWebAccount *sa, const gchar *convname, const gchar *m gint
skypeweb_chat_send(PurpleConnection *pc, gint id, const gchar *message, PurpleMessageFlags flags)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
- PurpleConversation *conv;
+ PurpleChatConversation *chatconv;
gchar* chatname;
- conv = purple_find_chat(pc, id);
- chatname = (gchar *)g_hash_table_lookup(conv->data, "chatname");
+ chatconv = purple_conversations_find_chat(pc, id);
+ chatname = purple_conversation_get_data(PURPLE_CONVERSATION(chatconv), "chatname");
if (!chatname)
return -1;
skypeweb_send_message(sa, chatname, message);
- serv_got_chat_in(pc, id, sa->username, PURPLE_MESSAGE_SEND, message, time(NULL));
+ purple_serv_got_chat_in(pc, id, sa->username, PURPLE_MESSAGE_SEND, message, time(NULL));
return 1;
}
@@ -988,7 +991,7 @@ skypeweb_chat_send(PurpleConnection *pc, gint id, const gchar *message, PurpleMe gint
skypeweb_send_im(PurpleConnection *pc, const gchar *who, const gchar *message, PurpleMessageFlags flags)
{
- SkypeWebAccount *sa = pc->proto_data;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
gchar *convname;
convname = g_strconcat("8:", who, NULL);
@@ -1002,14 +1005,14 @@ skypeweb_send_im(PurpleConnection *pc, const gchar *who, const gchar *message, P void
skypeweb_chat_invite(PurpleConnection *pc, int id, const char *message, const char *who)
{
- SkypeWebAccount *sa = pc->proto_data;
- PurpleConversation *conv;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
+ PurpleChatConversation *chatconv;
gchar *chatname;
gchar *post;
GString *url;
- conv = purple_find_chat(pc, id);
- chatname = (gchar *)g_hash_table_lookup(conv->data, "chatname");
+ chatconv = purple_conversations_find_chat(pc, id);
+ chatname = purple_conversation_get_data(PURPLE_CONVERSATION(chatconv), "chatname");
url = g_string_new("/v1/threads/");
g_string_append_printf(url, "%s", purple_url_encode(chatname));
@@ -1026,14 +1029,14 @@ skypeweb_chat_invite(PurpleConnection *pc, int id, const char *message, const ch void
skypeweb_chat_kick(PurpleConnection *pc, int id, const char *who)
{
- SkypeWebAccount *sa = pc->proto_data;
- PurpleConversation *conv;
+ SkypeWebAccount *sa = purple_connection_get_protocol_data(pc);
+ PurpleChatConversation *chatconv;
gchar *chatname;
gchar *post;
GString *url;
- conv = purple_find_chat(pc, id);
- chatname = (gchar *)g_hash_table_lookup(conv->data, "chatname");
+ chatconv = purple_conversations_find_chat(pc, id);
+ chatname = purple_conversation_get_data(PURPLE_CONVERSATION(chatconv), "chatname");
url = g_string_new("/v1/threads/");
g_string_append_printf(url, "%s", purple_url_encode(chatname));
@@ -1083,7 +1086,7 @@ skypeweb_initiate_chat(SkypeWebAccount *sa, const gchar *who) void
skypeweb_initiate_chat_from_node(PurpleBlistNode *node, gpointer userdata)
{
- if(PURPLE_BLIST_NODE_IS_BUDDY(node))
+ if(PURPLE_IS_BUDDY(node))
{
PurpleBuddy *buddy = (PurpleBuddy *) node;
SkypeWebAccount *sa;
@@ -1091,10 +1094,10 @@ skypeweb_initiate_chat_from_node(PurpleBlistNode *node, gpointer userdata) if (userdata) {
sa = userdata;
} else {
- PurpleConnection *pc = purple_account_get_connection(buddy->account);
- sa = pc->proto_data;
+ PurpleConnection *pc = purple_account_get_connection(purple_buddy_get_account(buddy));
+ sa = purple_connection_get_protocol_data(pc);
}
- skypeweb_initiate_chat(sa, buddy->name);
+ skypeweb_initiate_chat(sa, purple_buddy_get_name(buddy));
}
}
diff --git a/skypeweb/skypeweb_messages.h b/skypeweb/skypeweb_messages.h index d8fd2c0..1bafcb9 100644 --- a/skypeweb/skypeweb_messages.h +++ b/skypeweb/skypeweb_messages.h @@ -25,7 +25,7 @@ gint skypeweb_send_im(PurpleConnection *pc, const gchar *who, const gchar *msg, gint skypeweb_chat_send(PurpleConnection *pc, gint id, const gchar *message, PurpleMessageFlags flags); void skypeweb_set_idle(PurpleConnection *pc, int time); void skypeweb_set_status(PurpleAccount *account, PurpleStatus *status); -guint skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleTypingState state); +guint skypeweb_send_typing(PurpleConnection *pc, const gchar *name, PurpleIMTypingState state); void skypeweb_poll(SkypeWebAccount *sa); void skypeweb_get_registration_token(SkypeWebAccount *sa); void skypeweb_chat_kick(PurpleConnection *pc, int id, const char *who); @@ -41,6 +41,6 @@ void skypeweb_get_conversation_history(SkypeWebAccount *sa, const gchar *convnam void skypeweb_get_thread_users(SkypeWebAccount *sa, const gchar *convname); void skypeweb_get_all_conversations_since(SkypeWebAccount *sa, time_t since); void skype_web_get_offline_history(SkypeWebAccount *sa); -void skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConvUpdateType type); +void skypeweb_mark_conv_seen(PurpleConversation *conv, PurpleConversationUpdateType type); #endif /* SKYPEWEB_MESSAGES_H */ diff --git a/skypeweb/skypeweb_util.c b/skypeweb/skypeweb_util.c index 12b2e39..e91a251 100644 --- a/skypeweb/skypeweb_util.c +++ b/skypeweb/skypeweb_util.c @@ -18,7 +18,11 @@ #include "skypeweb_util.h"
-#include <cipher.h>
+#if !PURPLE_VERSION_CHECK(3, 0, 0)
+# include "cipher.h"
+#else
+# include "ciphers/sha256hash.h"
+#endif
gchar *
skypeweb_string_get_chunk(const gchar *haystack, gsize len, const gchar *start, const gchar *end)
@@ -117,8 +121,7 @@ skypeweb_thread_url_to_name(const gchar *url) char *
skypeweb_hmac_sha256(char *input)
{
- PurpleCipher *cipher;
- PurpleCipherContext *context;
+ PurpleHash *hash;
const guchar productKey[] = SKYPEWEB_LOCKANDKEY_SECRET;
const guchar productID[] = SKYPEWEB_LOCKANDKEY_APPID;
const char hexChars[] = "0123456789abcdef";
@@ -135,14 +138,11 @@ skypeweb_hmac_sha256(char *input) int len;
int i;
- /* Create the SHA256 hash by using Purple SHA256 algorithm */
- cipher = purple_ciphers_find_cipher("sha256");
- context = purple_cipher_context_new(cipher, NULL);
-
- purple_cipher_context_append(context, (guchar *)input, strlen(input));
- purple_cipher_context_append(context, productKey, sizeof(productKey) - 1);
- purple_cipher_context_digest(context, sizeof(sha256Hash), sha256Hash, NULL);
- purple_cipher_context_destroy(context);
+ hash = purple_sha256_hash_new();
+ purple_hash_append(hash, (guchar *)input, strlen(input));
+ purple_hash_append(hash, productKey, sizeof(productKey) - 1);
+ purple_hash_digest(hash, (guchar *)sha256Hash, sizeof(sha256Hash));
+ purple_hash_destroy(hash);
/* Split it into four integers */
sha256Parts = (unsigned int *)sha256Hash;
|