Removed unused stuff from libpurple backend
This commit is contained in:
parent
9f934c7a1f
commit
448a9173df
7 changed files with 1 additions and 382 deletions
|
@ -14,8 +14,6 @@
|
|||
#include "transport/conversation.h"
|
||||
#include "transport/networkplugin.h"
|
||||
#include "spectrumeventloop.h"
|
||||
#include "spectrumbuddy.h"
|
||||
#include "spectrumconversation.h"
|
||||
#include "geventloop.h"
|
||||
|
||||
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
|
||||
|
@ -34,8 +32,6 @@ static gchar *lock_file = NULL;
|
|||
static gchar *host = NULL;
|
||||
static int port = 10000;
|
||||
static gboolean ver = FALSE;
|
||||
static gboolean upgrade_db = FALSE;
|
||||
static gboolean check_db_version = FALSE;
|
||||
static gboolean list_purple_settings = FALSE;
|
||||
|
||||
static GOptionEntry options_entries[] = {
|
||||
|
@ -110,7 +106,6 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
|
|||
}
|
||||
|
||||
void handleMessageSendRequest(const std::string &user, const std::string &legacyName, const std::string &message) {
|
||||
const char *protocol = CONFIG_STRING(config, "service.protocol").c_str();
|
||||
PurpleAccount *account = m_sessions[user];
|
||||
if (account) {
|
||||
PurpleConversation *conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, legacyName.c_str(), account);
|
||||
|
@ -138,14 +133,6 @@ static std::string getAlias(PurpleBuddy *m_buddy) {
|
|||
return alias;
|
||||
}
|
||||
|
||||
static std::string getName(PurpleBuddy *m_buddy) {
|
||||
std::string name(purple_buddy_get_name(m_buddy));
|
||||
if (name.empty()) {
|
||||
Log("getName", "Name is EMPTY!");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
static bool getStatus(PurpleBuddy *m_buddy, Swift::StatusShow &status, std::string &statusMessage) {
|
||||
PurplePresence *pres = purple_buddy_get_presence(m_buddy);
|
||||
if (pres == NULL)
|
||||
|
@ -275,18 +262,7 @@ static void buddySignedOff(PurpleBuddy *buddy) {
|
|||
static void NodeRemoved(PurpleBlistNode *node, void *data) {
|
||||
if (!PURPLE_BLIST_NODE_IS_BUDDY(node))
|
||||
return;
|
||||
PurpleBuddy *buddy = (PurpleBuddy *) node;
|
||||
|
||||
// PurpleAccount *account = purple_buddy_get_account(buddy);
|
||||
// User *user = (User *) account->ui_data;
|
||||
if (buddy->node.ui_data) {
|
||||
SpectrumBuddy *s_buddy = (SpectrumBuddy *) buddy->node.ui_data;
|
||||
s_buddy->removeBuddy(buddy);
|
||||
buddy->node.ui_data = NULL;
|
||||
if (s_buddy->getBuddiesCount() == 0) {
|
||||
delete s_buddy;
|
||||
}
|
||||
}
|
||||
// PurpleBuddy *buddy = (PurpleBuddy *) node;
|
||||
}
|
||||
|
||||
static PurpleBlistUiOps blistUiOps =
|
||||
|
@ -307,29 +283,6 @@ static PurpleBlistUiOps blistUiOps =
|
|||
NULL
|
||||
};
|
||||
|
||||
static void conv_new(PurpleConversation *conv) {
|
||||
PurpleAccount *account = purple_conversation_get_account(conv);
|
||||
User *user = (User *) account->ui_data;
|
||||
|
||||
if (!user)
|
||||
return;
|
||||
|
||||
std::string name = purple_conversation_get_name(conv);
|
||||
size_t pos = name.find("/");
|
||||
if (pos != std::string::npos)
|
||||
name.erase((int) pos, name.length() - (int) pos);
|
||||
|
||||
SpectrumConversation *s_conv = new SpectrumConversation(user->getConversationManager(), name, conv);
|
||||
conv->ui_data = s_conv;
|
||||
}
|
||||
|
||||
static void conv_destroy(PurpleConversation *conv) {
|
||||
SpectrumConversation *s_conv = (SpectrumConversation *) conv->ui_data;
|
||||
if (s_conv) {
|
||||
delete s_conv;
|
||||
}
|
||||
}
|
||||
|
||||
static void conv_write_im(PurpleConversation *conv, const char *who, const char *message, PurpleMessageFlags flags, time_t mtime) {
|
||||
// Don't forwards our own messages.
|
||||
if (flags & PURPLE_MESSAGE_SEND || flags & PURPLE_MESSAGE_SYSTEM)
|
||||
|
@ -459,8 +412,6 @@ static bool initPurple(Config &cfg) {
|
|||
|
||||
ret = purple_core_init("spectrum");
|
||||
if (ret) {
|
||||
static int conversation_handle;
|
||||
static int conn_handle;
|
||||
static int blist_handle;
|
||||
|
||||
purple_set_blist(purple_blist_new());
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
#include "spectrum.h"
|
||||
#include "transport/config.h"
|
||||
#include "transport/transport.h"
|
||||
#include "transport/usermanager.h"
|
||||
#include "transport/logger.h"
|
||||
#include "transport/sqlite3backend.h"
|
||||
#include "transport/userregistration.h"
|
||||
|
||||
Spectrum::Spectrum(const std::string &config) {
|
||||
|
||||
}
|
||||
|
||||
Spectrum::~Spectrum() {
|
||||
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
/**
|
||||
* XMPP - libpurple transport
|
||||
*
|
||||
* Copyright (C) 2011, Jan Kaluza <hanzz@soc.pidgin.im>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "transport/transport.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
class Spectrum {
|
||||
public:
|
||||
Spectrum(const std::string &config);
|
||||
~Spectrum();
|
||||
|
||||
private:
|
||||
Component *m_component;
|
||||
};
|
|
@ -1,138 +0,0 @@
|
|||
/**
|
||||
* XMPP - libpurple transport
|
||||
*
|
||||
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
|
||||
*
|
||||
* 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 "spectrumbuddy.h"
|
||||
#include "transport/user.h"
|
||||
|
||||
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
|
||||
|
||||
SpectrumBuddy::SpectrumBuddy(RosterManager *rosterManager, long id, PurpleBuddy *buddy) : Buddy(rosterManager, id), m_buddy(buddy) {
|
||||
}
|
||||
|
||||
SpectrumBuddy::~SpectrumBuddy() {
|
||||
}
|
||||
|
||||
|
||||
std::string SpectrumBuddy::getAlias() {
|
||||
std::string alias;
|
||||
if (purple_buddy_get_server_alias(m_buddy))
|
||||
alias = (std::string) purple_buddy_get_server_alias(m_buddy);
|
||||
else
|
||||
alias = (std::string) purple_buddy_get_alias(m_buddy);
|
||||
return alias;
|
||||
}
|
||||
|
||||
std::string SpectrumBuddy::getName() {
|
||||
std::string name(purple_buddy_get_name(m_buddy));
|
||||
if (name.empty()) {
|
||||
Log("SpectrumBuddy::getName", "Name is EMPTY!");
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
bool SpectrumBuddy::getStatus(Swift::StatusShow &status, std::string &statusMessage) {
|
||||
PurplePresence *pres = purple_buddy_get_presence(m_buddy);
|
||||
if (pres == NULL)
|
||||
return false;
|
||||
PurpleStatus *stat = purple_presence_get_active_status(pres);
|
||||
if (stat == NULL)
|
||||
return false;
|
||||
int st = purple_status_type_get_primitive(purple_status_get_type(stat));
|
||||
|
||||
switch(st) {
|
||||
case PURPLE_STATUS_AVAILABLE: {
|
||||
break;
|
||||
}
|
||||
case PURPLE_STATUS_AWAY: {
|
||||
status = Swift::StatusShow::Away;
|
||||
break;
|
||||
}
|
||||
case PURPLE_STATUS_UNAVAILABLE: {
|
||||
status = Swift::StatusShow::DND;
|
||||
break;
|
||||
}
|
||||
case PURPLE_STATUS_EXTENDED_AWAY: {
|
||||
status = Swift::StatusShow::XA;
|
||||
break;
|
||||
}
|
||||
case PURPLE_STATUS_OFFLINE: {
|
||||
status = Swift::StatusShow::None;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
const char *message = purple_status_get_attr_string(stat, "message");
|
||||
|
||||
if (message != NULL) {
|
||||
char *stripped = purple_markup_strip_html(message);
|
||||
statusMessage = std::string(stripped);
|
||||
g_free(stripped);
|
||||
}
|
||||
else
|
||||
statusMessage = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string SpectrumBuddy::getIconHash() {
|
||||
char *avatarHash = NULL;
|
||||
PurpleBuddyIcon *icon = purple_buddy_icons_find(purple_buddy_get_account(m_buddy), purple_buddy_get_name(m_buddy));
|
||||
if (icon) {
|
||||
avatarHash = purple_buddy_icon_get_full_path(icon);
|
||||
Log(getName(), "avatarHash");
|
||||
}
|
||||
|
||||
if (avatarHash) {
|
||||
Log(getName(), "Got avatar hash");
|
||||
// Check if it's patched libpurple which saves icons to directories
|
||||
char *hash = strrchr(avatarHash,'/');
|
||||
std::string h;
|
||||
if (hash) {
|
||||
char *dot;
|
||||
hash++;
|
||||
dot = strchr(hash, '.');
|
||||
if (dot)
|
||||
*dot = '\0';
|
||||
|
||||
std::string ret(hash);
|
||||
g_free(avatarHash);
|
||||
return ret;
|
||||
}
|
||||
else {
|
||||
std::string ret(avatarHash);
|
||||
g_free(avatarHash);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
std::vector<std::string> SpectrumBuddy::getGroups() {
|
||||
std::vector<std::string> groups;
|
||||
groups.push_back(purple_group_get_name(purple_buddy_get_group(m_buddy)) ? std::string(purple_group_get_name(purple_buddy_get_group(m_buddy))) : std::string("Buddies"));
|
||||
return groups;
|
||||
}
|
||||
|
||||
void SpectrumBuddy::getVCard(const std::string &id, const Swift::JID &to) {
|
||||
|
||||
}
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/**
|
||||
* XMPP - libpurple transport
|
||||
*
|
||||
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
|
||||
*
|
||||
* 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 SPECTRUM_BUDDY_H
|
||||
#define SPECTRUM_BUDDY_H
|
||||
|
||||
#include <string>
|
||||
#include "purple.h"
|
||||
#include "account.h"
|
||||
#include "glib.h"
|
||||
#include <algorithm>
|
||||
#include "transport/buddy.h"
|
||||
#include "transport/rostermanager.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
// Wrapper for PurpleBuddy
|
||||
class SpectrumBuddy : public Buddy {
|
||||
public:
|
||||
SpectrumBuddy(RosterManager *rosterManager, long id, PurpleBuddy *buddy);
|
||||
virtual ~SpectrumBuddy();
|
||||
|
||||
std::string getAlias();
|
||||
std::string getName();
|
||||
bool getStatus(Swift::StatusShow &status, std::string &statusMessage);
|
||||
std::string getIconHash();
|
||||
std::vector<std::string> getGroups();
|
||||
|
||||
void addBuddy(PurpleBuddy *buddy) { m_buddies.push_back(buddy); }
|
||||
void removeBuddy(PurpleBuddy *buddy) { m_buddies.remove(buddy); }
|
||||
int getBuddiesCount() { return m_buddies.size(); }
|
||||
void getVCard(const std::string &id, const Swift::JID &to);
|
||||
|
||||
PurpleBuddy *getBuddy() { return m_buddy; }
|
||||
|
||||
private:
|
||||
PurpleBuddy *m_buddy;
|
||||
std::list<PurpleBuddy *> m_buddies;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
/**
|
||||
* XMPP - libpurple transport
|
||||
*
|
||||
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
|
||||
*
|
||||
* 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 "spectrumconversation.h"
|
||||
#include "transport/user.h"
|
||||
|
||||
#define Log(X, STRING) std::cout << "[SPECTRUM] " << X << " " << STRING << "\n";
|
||||
|
||||
SpectrumConversation::SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv) : Conversation(conversationManager, legacyName), m_conv(conv) {
|
||||
}
|
||||
|
||||
SpectrumConversation::~SpectrumConversation() {
|
||||
}
|
||||
|
||||
void SpectrumConversation::sendMessage(boost::shared_ptr<Swift::Message> &message) {
|
||||
// escape and send
|
||||
gchar *_markup = purple_markup_escape_text(message->getBody().c_str(), -1);
|
||||
if (purple_conversation_get_type(m_conv) == PURPLE_CONV_TYPE_IM) {
|
||||
purple_conv_im_send(PURPLE_CONV_IM(m_conv), _markup);
|
||||
}
|
||||
g_free(_markup);
|
||||
}
|
||||
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/**
|
||||
* XMPP - libpurple transport
|
||||
*
|
||||
* Copyright (C) 2009, Jan Kaluza <hanzz@soc.pidgin.im>
|
||||
*
|
||||
* 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
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "purple.h"
|
||||
#include "account.h"
|
||||
#include "glib.h"
|
||||
#include <algorithm>
|
||||
#include "transport/conversation.h"
|
||||
#include "transport/conversationmanager.h"
|
||||
#include "transport/user.h"
|
||||
|
||||
using namespace Transport;
|
||||
|
||||
// Wrapper for PurpleBuddy
|
||||
class SpectrumConversation : public Conversation {
|
||||
public:
|
||||
SpectrumConversation(ConversationManager *conversationManager, const std::string &legacyName, PurpleConversation *conv);
|
||||
virtual ~SpectrumConversation();
|
||||
|
||||
PurpleConversation *getConversation() { return m_conv; }
|
||||
|
||||
void sendMessage(boost::shared_ptr<Swift::Message> &message);
|
||||
|
||||
private:
|
||||
PurpleConversation *m_conv;
|
||||
};
|
||||
|
Loading…
Add table
Reference in a new issue