Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
icq: Add signals for ICQ specific functions
Browse files Browse the repository at this point in the history
  • Loading branch information
flynd committed Dec 17, 2012
1 parent 74f9f41 commit 4497581
Show file tree
Hide file tree
Showing 6 changed files with 1,164 additions and 0 deletions.
1 change: 1 addition & 0 deletions licq/include/licq/protocolsignal.h
Expand Up @@ -65,6 +65,7 @@ class ProtocolSignal
SignalRenameGroup = 30, // Rename a user group
SignalRemoveGroup = 31, // Remove a user group
SignalSendUrl = 32, // Send an URL to a user
SignalProtocolSpecific = 33, // Protocol specific signal
};

// Flags for send events
Expand Down
1 change: 1 addition & 0 deletions licq/src/CMakeLists.txt
Expand Up @@ -64,6 +64,7 @@ set(licq_SRCS
icq/owner.cpp
icq/packet-srv.cpp
icq/packet-tcp.cpp
icq/protocolsignal.cpp
icq/rtf.cc
icq/socket.cpp
icq/threads.cpp
Expand Down
244 changes: 244 additions & 0 deletions licq/src/icq/icqprotocolplugin.cpp
Expand Up @@ -20,10 +20,12 @@
#include "icqprotocolplugin.h"

#include <licq/logging/log.h>
#include <licq/protocolmanager.h>
#include <licq/protocolsignal.h>
#include <licq/version.h>
#include "icq.h"
#include "owner.h"
#include "protocolsignal.h"
#include "user.h"

#define LicqProtocolPluginData IcqProtocolPluginData
Expand Down Expand Up @@ -124,6 +126,248 @@ void IcqProtocolPlugin::processPipe()
}
}

bool IcqProtocolPlugin::isOwnerOnline(const Licq::UserId& userId)
{
Licq::OwnerReadGuard owner(userId.protocolId());
return owner.isLocked() && owner->isOnline();
}

unsigned long IcqProtocolPlugin::icqSendContactList(const Licq::UserId& userId,
const Licq::StringList& users, unsigned flags, const Licq::Color* color)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoSendContactsSignal(eventId, userId, users, flags, color));
return eventId;
}

unsigned long IcqProtocolPlugin::icqFetchAutoResponse(const Licq::UserId& userId)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoFetchAutoResponseSignal(eventId, userId));
return eventId;
}

unsigned long IcqProtocolPlugin::icqChatRequest(const Licq::UserId& userId, const std::string& reason,
unsigned flags, const std::string& chatUsers, unsigned short port)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoChatRequestSignal(eventId, userId, reason, flags, chatUsers, port));
return eventId;
}

void IcqProtocolPlugin::icqChatRequestRefuse(const Licq::UserId& userId, const std::string& reason,
unsigned short sequence, unsigned long msgid1, unsigned long msgid2, bool direct)
{
if (!isOwnerOnline(userId))
return;

pushSignal(new ProtoChatRefuseSignal(userId, reason, sequence, msgid1, msgid2, direct));
}

void IcqProtocolPlugin::icqChatRequestAccept(const Licq::UserId& userId, unsigned short port,
const std::string& clients, unsigned short sequence,
unsigned long msgid1, unsigned long msgid2, bool direct)
{
if (!isOwnerOnline(userId))
return;

pushSignal(new ProtoChatAcceptSignal(userId, port, clients, sequence, msgid1, msgid2, direct));
}

unsigned long IcqProtocolPlugin::icqRequestPluginInfo(const Licq::UserId& userId,
Licq::IcqProtocol::PluginType type, bool server)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoRequestPluginSignal(eventId, userId, type, server));
return eventId;
}

void IcqProtocolPlugin::icqUpdateInfoTimestamp(const Licq::UserId& ownerId, Licq::IcqProtocol::PluginType type)
{
if (!isOwnerOnline(ownerId))
return;

pushSignal(new ProtoUpdateTimestampSignal(ownerId, type));
}

unsigned long IcqProtocolPlugin::icqSetWorkInfo(const Licq::UserId& ownerId,
const std::string& city, const std::string& state, const std::string& phone,
const std::string& fax, const std::string& address, const std::string& zip,
unsigned short country, const std::string& name, const std::string& department,
const std::string& position, unsigned short occupation, const std::string& homepage)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateWorkSignal(eventId, ownerId, city, state, phone, fax, address,
zip, country, name, department, position, occupation, homepage));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetEmailInfo(const Licq::UserId& ownerId,
const std::string& emailSecondary, const std::string& emailOld)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateEmailSignal(eventId, ownerId, emailSecondary, emailOld));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetMoreInfo(const Licq::UserId& ownerId,
unsigned short age, char gender, const std::string& homepage,
unsigned short birthYear, char birthMonth, char birthDay,
char language1, char language2, char language3)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateMoreSignal(eventId, ownerId, age, gender, homepage,
birthYear, birthMonth, birthDay, language1, language2, language3));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetSecurityInfo(const Licq::UserId& ownerId,
bool authorize, bool webAware)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateSecuritySignal(eventId, ownerId, authorize, webAware));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetInterestsInfo(const Licq::UserId& ownerId,
const Licq::UserCategoryMap& interests)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateInterestsSignal(eventId, ownerId, interests));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetOrgBackInfo(const Licq::UserId& ownerId,
const Licq::UserCategoryMap& organisations, const Licq::UserCategoryMap& background)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateOrgBackSignal(eventId, ownerId, organisations, background));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSetAbout(const Licq::UserId& ownerId, const std::string& about)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateAboutSignal(eventId, ownerId, about));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSearchWhitePages(const Licq::UserId& ownerId,
const std::string& firstName, const std::string& lastName, const std::string& alias,
const std::string& email, unsigned short minAge, unsigned short maxAge, char gender,
char language, const std::string& city, const std::string& state, unsigned short country,
const std::string& coName, const std::string& coDept, const std::string& coPos,
const std::string& keyword, bool onlineOnly)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoSearchWhitePagesSignal(eventId, ownerId, firstName, lastName,
alias, email, minAge, maxAge, gender, language, city, state, country, coName,
coDept, coPos, keyword, onlineOnly));
return eventId;
}

unsigned long IcqProtocolPlugin::icqSearchByUin(const Licq::UserId& userId)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoSearchUinSignal(eventId, userId));
return eventId;
}

void IcqProtocolPlugin::icqAlertUser(const Licq::UserId& userId)
{
if (!isOwnerOnline(userId))
return;

pushSignal(new ProtoAddedSignal(userId));
}

void IcqProtocolPlugin::icqSetPhoneFollowMeStatus(const Licq::UserId& ownerId, unsigned status)
{
if (!isOwnerOnline(ownerId))
return;

pushSignal(new ProtoSetPhoneFollowMeSignal(ownerId, status));
}

unsigned long IcqProtocolPlugin::setRandomChatGroup(const Licq::UserId& ownerId, unsigned chatGroup)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoUpdateRandomChatSignal(eventId, ownerId, chatGroup));
return eventId;
}

unsigned long IcqProtocolPlugin::randomChatSearch(const Licq::UserId& ownerId, unsigned chatGroup)
{
if (!isOwnerOnline(ownerId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoSearchRandomSignal(eventId, ownerId, chatGroup));
return eventId;
}

void IcqProtocolPlugin::updateAllUsersInGroup(const Licq::UserId& ownerId, int groupId)
{
if (!isOwnerOnline(ownerId))
return;

pushSignal(new ProtoUpdateUsersSignal(ownerId, groupId));
}

unsigned long IcqProtocolPlugin::icqSendSms(const Licq::UserId& userId,
const std::string& number, const std::string& message)
{
if (!isOwnerOnline(userId))
return 0;

unsigned long eventId = Licq::gProtocolManager.getNextEventId();
pushSignal(new ProtoSendSmsSignal(eventId, userId, number, message));
return eventId;
}


Licq::ProtocolPlugin* IcqPluginFactory(Licq::ProtocolPlugin::Params& p)
{
return new LicqIcq::IcqProtocolPlugin(p);
Expand Down
44 changes: 44 additions & 0 deletions licq/src/icq/icqprotocolplugin.h
Expand Up @@ -21,6 +21,7 @@
#define LICQICQ_ICQPROTOCOLPLUGIN_H

#include <licq/plugin/protocolbase.h>
#include <licq/icq/icq.h>

namespace LicqIcq
{
Expand All @@ -44,6 +45,48 @@ class IcqProtocolPlugin : public Licq::ProtocolPlugin
std::string defaultServerHost() const;
int defaultServerPort() const;

// From Licq::IcqProtocol
unsigned long icqSendContactList(const Licq::UserId& userId, const Licq::StringList& users,
unsigned flags = 0, const Licq::Color* color = NULL);
unsigned long icqFetchAutoResponse(const Licq::UserId& userId);
unsigned long icqChatRequest(const Licq::UserId& userId, const std::string& reason,
unsigned flags = 0, const std::string& chatUsers = "", unsigned short port = 0);
void icqChatRequestRefuse(const Licq::UserId& userId, const std::string& reason,
unsigned short sequence, unsigned long msgid1, unsigned long msgid2, bool direct);
void icqChatRequestAccept(const Licq::UserId& userId, unsigned short port,
const std::string& clients, unsigned short sequence,
unsigned long msgid1, unsigned long msgid2, bool direct);
unsigned long icqRequestPluginInfo(const Licq::UserId& userId, Licq::IcqProtocol::PluginType type,
bool server = false);
void icqUpdateInfoTimestamp(const Licq::UserId& ownerId, Licq::IcqProtocol::PluginType type);
unsigned long icqSetWorkInfo(const Licq::UserId& ownerId, const std::string& city, const std::string& state,
const std::string& phone, const std::string& fax, const std::string& address,
const std::string& zip, unsigned short country, const std::string& name,
const std::string& department, const std::string& position, unsigned short occupation,
const std::string& homepage);
unsigned long icqSetEmailInfo(const Licq::UserId& ownerId, const std::string& emailSecondary, const std::string& emailOld);
unsigned long icqSetMoreInfo(const Licq::UserId& ownerId, unsigned short age, char gender,
const std::string& homepage, unsigned short birthYear, char birthMonth,
char birthDay, char language1, char language2, char language3);
unsigned long icqSetSecurityInfo(const Licq::UserId& ownerId, bool authorize, bool webAware);
unsigned long icqSetInterestsInfo(const Licq::UserId& ownerId, const Licq::UserCategoryMap& interests);
unsigned long icqSetOrgBackInfo(const Licq::UserId& ownerId, const Licq::UserCategoryMap& organisations,
const Licq::UserCategoryMap& background);
unsigned long icqSetAbout(const Licq::UserId& ownerId, const std::string& about);
unsigned long icqSearchWhitePages(const Licq::UserId& ownerId, const std::string& firstName, const std::string& lastName,
const std::string& alias, const std::string& email, unsigned short minAge, unsigned short maxAge,
char gender, char language, const std::string& city, const std::string& state,
unsigned short country, const std::string& coName, const std::string& coDept,
const std::string& coPos, const std::string& keyword, bool onlineOnly);
unsigned long icqSearchByUin(const Licq::UserId& userId);
void icqAlertUser(const Licq::UserId& userId);
void icqSetPhoneFollowMeStatus(const Licq::UserId& ownerId, unsigned status);
unsigned long setRandomChatGroup(const Licq::UserId& ownerId, unsigned chatGroup);
unsigned long randomChatSearch(const Licq::UserId& ownerId, unsigned chatGroup);
void updateAllUsersInGroup(const Licq::UserId& ownerId, int groupId = 0);
unsigned long icqSendSms(const Licq::UserId& userId,
const std::string& number, const std::string& message);

protected:
// From Licq::ProtocolPlugin
bool init(int, char**);
Expand All @@ -53,6 +96,7 @@ class IcqProtocolPlugin : public Licq::ProtocolPlugin
Licq::Owner* createOwner(const Licq::UserId& id);

private:
bool isOwnerOnline(const Licq::UserId& userId);

};

Expand Down

0 comments on commit 4497581

Please sign in to comment.