1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2012-2013 Licq developers <licq-dev@googlegroups.com>
4  *
5  * Licq is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * Licq is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with Licq; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef LICQICQ_ICQPROTOCOLPLUGIN_H
21 #define LICQICQ_ICQPROTOCOLPLUGIN_H
22 
23 #include <licq/plugin/protocolpluginhelper.h>
24 #include <licq/icq/icq.h>
25 
26 namespace LicqIcq
27 {
28 
29 class Factory;
30 
31 class IcqProtocolPlugin : public Licq::ProtocolPluginHelper, public Licq::IcqProtocol
32 {
33 public:
34   IcqProtocolPlugin();
35 
36   /// Read and process next event from plugin pipe
37   void processPipe();
38 
39   // Make read pipe available to monitor thread
40   using Licq::ProtocolPluginHelper::getReadPipe;
41 
42   // From Licq::PluginInterface
43   bool init(int argc, char** argv);
44   int run();
45 
46   std::string defaultServerHost() const;
47   int defaultServerPort() const;
48 
49   // From Licq::IcqProtocol
50   unsigned long icqSendContactList(const Licq::UserId& userId, const Licq::StringList& users,
51       unsigned flags = 0, const Licq::Color* color = NULL);
52   unsigned long icqFetchAutoResponse(const Licq::UserId& userId);
53   unsigned long icqChatRequest(const Licq::UserId& userId, const std::string& reason,
54       unsigned flags = 0, const std::string& chatUsers = "", unsigned short port = 0);
55   void icqChatRequestRefuse(const Licq::UserId& userId, const std::string& reason,
56       unsigned short sequence, unsigned long msgid1, unsigned long msgid2, bool direct);
57   void icqChatRequestAccept(const Licq::UserId& userId, unsigned short port,
58       const std::string& clients, unsigned short sequence,
59       unsigned long msgid1, unsigned long msgid2, bool direct);
60   unsigned long icqRequestPluginInfo(const Licq::UserId& userId, Licq::IcqProtocol::PluginType type,
61       bool server = false);
62   void icqUpdateInfoTimestamp(const Licq::UserId& ownerId, Licq::IcqProtocol::PluginType type);
63   unsigned long icqSetWorkInfo(const Licq::UserId& ownerId, const std::string& city, const std::string& state,
64       const std::string& phone, const std::string& fax, const std::string& address,
65       const std::string& zip, unsigned short country, const std::string& name,
66       const std::string& department, const std::string& position, unsigned short occupation,
67       const std::string& homepage);
68   unsigned long icqSetEmailInfo(const Licq::UserId& ownerId, const std::string& emailSecondary, const std::string& emailOld);
69   unsigned long icqSetMoreInfo(const Licq::UserId& ownerId, unsigned short age, char gender,
70       const std::string& homepage, unsigned short birthYear, char birthMonth,
71       char birthDay, char language1, char language2, char language3);
72   unsigned long icqSetSecurityInfo(const Licq::UserId& ownerId, bool authorize, bool webAware);
73   unsigned long icqSetInterestsInfo(const Licq::UserId& ownerId, const Licq::UserCategoryMap& interests);
74   unsigned long icqSetOrgBackInfo(const Licq::UserId& ownerId, const Licq::UserCategoryMap& organisations,
75       const Licq::UserCategoryMap& background);
76   unsigned long icqSetAbout(const Licq::UserId& ownerId, const std::string& about);
77   unsigned long icqSearchWhitePages(const Licq::UserId& ownerId, const std::string& firstName, const std::string& lastName,
78       const std::string& alias, const std::string& email, unsigned short minAge, unsigned short maxAge,
79       char gender, char language, const std::string& city, const std::string& state,
80       unsigned short country, const std::string& coName, const std::string& coDept,
81       const std::string& coPos, const std::string& keyword, bool onlineOnly);
82   unsigned long icqSearchByUin(const Licq::UserId& userId);
83   void icqAlertUser(const Licq::UserId& userId);
84   void icqSetPhoneFollowMeStatus(const Licq::UserId& ownerId, unsigned status);
85   unsigned long setRandomChatGroup(const Licq::UserId& ownerId, unsigned chatGroup);
86   unsigned long randomChatSearch(const Licq::UserId& ownerId, unsigned chatGroup);
87   void updateAllUsersInGroup(const Licq::UserId& ownerId, int groupId = 0);
88   unsigned long icqSendSms(const Licq::UserId& userId,
89       const std::string& number, const std::string& message);
90   Licq::IcqFileTransferManager* createFileTransferManager(const Licq::UserId& userId);
91   Licq::IcqChatManager* createChatManager(const Licq::UserId& userId);
92 
93 private:
94   bool isOwnerOnline(const Licq::UserId& userId);
95 
96   using ProtocolPluginHelper::pushSignal;
97   void pushSignal(Licq::ProtocolSignal* signal);
98 
99   friend class Factory;
100   ~IcqProtocolPlugin();
101 };
102 
103 extern IcqProtocolPlugin* gIcqProtocolPlugin;
104 
105 } // namespace LicqIcq
106 
107 #endif
108