Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 44 additions & 44 deletions backends/libpurple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "purple.h"
#include <algorithm>
#include <iostream>
#include <fstream>
#include <fstream>

#include "transport/NetworkPlugin.h"
#include "transport/Logging.h"
Expand Down Expand Up @@ -188,29 +188,29 @@ static std::string OAUTH_TOKEN = "hangouts_oauth_token";

static bool getUserOAuthToken(const std::string user, std::string &token)
{
boost::mutex::scoped_lock lock(dblock);
UserInfo info;
if(storagebackend->getUser(user, info) == false) {
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
return false;
}
token = "";
int type = TYPE_STRING;
storagebackend->getUserSetting((long)info.id, OAUTH_TOKEN, type, token);
return true;
boost::mutex::scoped_lock lock(dblock);
UserInfo info;
if(storagebackend->getUser(user, info) == false) {
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
return false;
}
token = "";
int type = TYPE_STRING;
storagebackend->getUserSetting((long)info.id, OAUTH_TOKEN, type, token);
return true;
}

static bool storeUserOAuthToken(const std::string user, const std::string OAuthToken)
{
boost::mutex::scoped_lock lock(dblock);
UserInfo info;
if(storagebackend->getUser(user, info) == false) {
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!")
return false;
}
storagebackend->updateUserSetting((long)info.id, OAUTH_TOKEN, OAuthToken);
return true;
}
boost::mutex::scoped_lock lock(dblock);
UserInfo info;
if(storagebackend->getUser(user, info) == false) {
LOG4CXX_ERROR(logger, "Didn't find entry for " << user << " in the database!");
return false;
}
storagebackend->updateUserSetting((long)info.id, OAUTH_TOKEN, OAuthToken);
return true;
}

class SpectrumNetworkPlugin : public NetworkPlugin {
public:
Expand Down Expand Up @@ -274,7 +274,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
if (strippedKey != key2) {
continue;
}

found = true;
switch (type) {
case PURPLE_PREF_BOOLEAN:
Expand Down Expand Up @@ -313,9 +313,9 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
std::string username(purple_account_get_username_wrapped(account));
std::vector <std::string> u = split(username, '@');
purple_account_set_username_wrapped(account, (const char*) u.front().c_str());
std::vector <std::string> s = split(u.back(), ':');
std::vector <std::string> s = split(u.back(), ':');
purple_account_set_string_wrapped(account, "server", s.front().c_str());
purple_account_set_int_wrapped(account, "port", atoi(s.back().c_str()));
purple_account_set_int_wrapped(account, "port", atoi(s.back().c_str()));
}

if (!CONFIG_STRING_DEFAULTED(config, "proxy.type", "").empty()) {
Expand Down Expand Up @@ -430,7 +430,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
}
// OAuth helper
if (protocol == "prpl-hangouts") {
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias)
LOG4CXX_INFO(logger, user << ": Adding Buddy " << adminLegacyName << " " << adminAlias);
handleBuddyChanged(user, adminLegacyName, adminAlias, std::vector<std::string>(), pbnetwork::STATUS_ONLINE);
}
}
Expand Down Expand Up @@ -532,7 +532,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
}
return;
}

if (!conv) {
conv = purple_find_conversation_with_account_wrapped(PURPLE_CONV_TYPE_IM, LegacyNameToName(account, legacyName).c_str(), account);
if (!conv) {
Expand Down Expand Up @@ -815,7 +815,7 @@ class SpectrumNetworkPlugin : public NetworkPlugin {
if (xfer) {
m_unhandledXfers.erase(user + fileName + buddyName);
FTData *ftData = (FTData *) xfer->ui_data;

ftData->id = ftID;
m_xfers[ftID] = xfer;
purple_xfer_request_accepted_wrapped(xfer, fileName.c_str());
Expand Down Expand Up @@ -1035,7 +1035,7 @@ void buddyListNewNode(PurpleBlistNode *node) {
cache->nodes[node] = 1;
return;
}


std::vector<std::string> groups = getGroups(buddy);
LOG4CXX_INFO(logger, "Buddy updated " << np->m_accounts[account] << " " << purple_buddy_get_name_wrapped(buddy) << " " << getAlias(buddy) << " group (" << groups.size() << ")=" << groups[0]);
Expand Down Expand Up @@ -1191,7 +1191,7 @@ static void conv_write(PurpleConversation *conv, const char *who, const char *al
std::string conversationName = purple_conversation_get_name_wrapped(conv);
LOG4CXX_INFO(logger, "Received message body='" << message_ << "' name='" << conversationName << "' " << who);
np->handleMessage(np->m_accounts[account], np->NameToLegacyName(account, conversationName), message_, who, xhtml_, timestamp);
}
}
}
}

Expand Down Expand Up @@ -1278,7 +1278,7 @@ static void conv_write_im(PurpleConversation *conv, const char *who, const char
return;
}
purple_imgstore_unref_wrapped(image);

std::string src = CONFIG_STRING(config, "service.web_url") + "/" + name + "." + ext;
std::string img = "<img src=\"" + src + "\"/>";
boost::replace_all(body, "<img id=\"" + id + "\">", img);
Expand Down Expand Up @@ -1488,7 +1488,7 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
if (pos != std::string::npos)
name.erase((int) pos, name.length() - (int) pos);


GList *vcardEntries = purple_notify_user_info_get_entries_wrapped(user_info);
PurpleNotifyUserInfoEntry *vcardEntry;
std::string firstName;
Expand Down Expand Up @@ -1581,7 +1581,7 @@ static void *notify_user_info(PurpleConnection *gc, const char *who, PurpleNotif
purple_buddy_icon_unref_wrapped(icon);
}
}

np->handleVCard(np->m_accounts[account], np->m_vcards[np->m_accounts[account] + name], name, fullName, nickname, photo);
np->m_vcards.erase(np->m_accounts[account] + name);

Expand Down Expand Up @@ -1833,7 +1833,7 @@ static gssize XferRead(PurpleXfer *xfer, guchar **buffer, gssize size) {
// int data_size = repeater->getDataToSend(buffer, size);
// if (data_size == 0)
// return 0;
//
//
// return data_size;
return 0;
}
Expand Down Expand Up @@ -1880,7 +1880,7 @@ static void RoomlistProgress(PurpleRoomlist *list, gboolean in_progress)
GList *rooms;
std::list<std::string> m_topics;
for (rooms = list->rooms; rooms != NULL; rooms = rooms->next) {
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
PurpleRoomlistRoom *room = (PurpleRoomlistRoom *)rooms->data;
np->m_rooms[np->m_accounts[list->account]].push_back(room->name);

if (topicId == -1) {
Expand Down Expand Up @@ -1947,7 +1947,7 @@ static void transport_core_ui_init(void)
purple_connections_set_ui_ops_wrapped(&conn_ui_ops);
purple_conversations_set_ui_ops_wrapped(&conversation_ui_ops);
purple_roomlist_set_ui_ops_wrapped(&roomlist_ui_ops);

// #ifndef WIN32
// purple_dnsquery_set_ui_ops_wrapped(getDNSUiOps());
// #endif
Expand Down Expand Up @@ -2018,7 +2018,7 @@ debug_init(void)
REGISTER_G_LOG_HANDLER("GLib-GObject");
REGISTER_G_LOG_HANDLER("GThread");
REGISTER_G_LOG_HANDLER("GConf");


#undef REGISTER_G_LOD_HANDLER
}
Expand All @@ -2045,7 +2045,7 @@ static void signed_on(PurpleConnection *gc, gpointer unused) {
#endif
#endif
purple_roomlist_get_list_wrapped(gc);

// For prpl-gg
execute_purple_plugin_action(gc, "Download buddylist from Server");
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
Expand Down Expand Up @@ -2129,7 +2129,7 @@ static bool initPurple() {
std::string cacertsDir = CONFIG_STRING_DEFAULTED(config, "purple.cacerts_dir", "./ca-certs");
LOG4CXX_INFO(logger, "Setting libpurple cacerts directory to: " << cacertsDir);
purple_certificate_add_ca_search_path_wrapped(cacertsDir.c_str());

std::string userDir = CONFIG_STRING_DEFAULTED(config, "service.working_dir", "./");
LOG4CXX_INFO(logger, "Setting libpurple user directory to: " << userDir);

Expand Down Expand Up @@ -2196,7 +2196,7 @@ static bool initPurple() {
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-request", &xfer_handle, PURPLE_CALLBACK(newXfer), NULL);
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-recv-complete", &xfer_handle, PURPLE_CALLBACK(XferReceiveComplete), NULL);
purple_signal_connect_wrapped(purple_xfers_get_handle_wrapped(), "file-send-complete", &xfer_handle, PURPLE_CALLBACK(XferSendComplete), NULL);
//
//
// purple_commands_init();

}
Expand Down Expand Up @@ -2224,7 +2224,7 @@ static void transportDataReceived(gpointer data, gint source, PurpleInputConditi

if (firstPing) {
firstPing = false;
NetworkPlugin::PluginConfig cfg;
NetworkPlugin::PluginConfig cfg;
cfg.setSupportMUC(true);
if (CONFIG_STRING(config, "service.protocol") == "prpl-telegram") {
cfg.setNeedPassword(false);
Expand Down Expand Up @@ -2277,7 +2277,7 @@ int main(int argc, char **argv) {
}

config = SWIFTEN_SHRPTR_NAMESPACE::shared_ptr<Config>(cfg);

Logging::initBackendLogging(config.get());
if (CONFIG_STRING(config, "service.protocol") == "prpl-hangouts") {
storagebackend = StorageBackend::createBackend(config.get(), error);
Expand All @@ -2287,17 +2287,17 @@ int main(int argc, char **argv) {
return NetworkPlugin::StorageBackendNeeded;
}
else if (!storagebackend->connect()) {
LOG4CXX_ERROR(logger, "Can't connect to database!")
return -1;
LOG4CXX_ERROR(logger, "Can't connect to database!");
return -1;
}
}

initPurple();

main_socket = create_socket(host.c_str(), port);
purple_input_add_wrapped(main_socket, PURPLE_INPUT_READ, &transportDataReceived, NULL);
purple_timeout_add_seconds_wrapped(30, pingTimeout, NULL);

np = new SpectrumNetworkPlugin();
bool libev = CONFIG_STRING_DEFAULTED(config, "service.eventloop", "") == "libev";

Expand Down
6 changes: 3 additions & 3 deletions backends/smstools3/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class SMSNetworkPlugin : public NetworkPlugin {


void handleSMS(const std::string &sms) {
LOG4CXX_INFO(logger, "Handling SMS " << sms << ".")
LOG4CXX_INFO(logger, "Handling SMS " << sms << ".");
std::ifstream t(sms.c_str());
std::string str;

Expand Down Expand Up @@ -149,7 +149,7 @@ class SMSNetworkPlugin : public NetworkPlugin {
}

void sendSMS(const std::string &to, const std::string &msg) {
// TODO: Probably
// TODO: Probably
std::string data = "To: " + to + "\n";
data += "\n";
data += msg;
Expand Down Expand Up @@ -232,7 +232,7 @@ class SMSNetworkPlugin : public NetworkPlugin {


private:

Config *config;
};

Expand Down
Loading