1 /*
2  * This file is part of Licq, an instant messaging client for UNIX.
3  * Copyright (C) 2004-2014 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 #include <licq/plugin/protocolplugin.h>
21 #include <licq/plugin/protocolpluginfactory.h>
22 #include <licq/version.h>
23 
24 #include "msn.h"
25 #include "owner.h"
26 #include "pluginversion.h"
27 #include "user.h"
28 
29 namespace LicqMsn
30 {
31 
32 class Factory : public Licq::ProtocolPluginFactory
33 {
34 public:
35   // From Licq::PluginFactory
name() const36   std::string name() const { return "MSN"; }
version() const37   std::string version() const { return PLUGIN_VERSION_STRING; }
destroyPlugin(Licq::PluginInterface * plugin)38   void destroyPlugin(Licq::PluginInterface* plugin) { delete plugin; }
39 
40   // From Licq::ProtocolPluginFactory
protocolId() const41   unsigned long protocolId() const { return MSN_PPID; }
42   unsigned long capabilities() const;
43   unsigned long statuses() const;
44   Licq::ProtocolPluginInterface* createPlugin();
45   Licq::User* createUser(const Licq::UserId& id, bool temporary);
46   Licq::Owner* createOwner(const Licq::UserId& id);
47 };
48 
capabilities() const49 unsigned long Factory::capabilities() const
50 {
51   using Licq::ProtocolPlugin;
52 
53   return ProtocolPlugin::CanSendMsg
54       | ProtocolPlugin::CanSendAuth
55       | ProtocolPlugin::CanSendAuthReq
56       | ProtocolPlugin::CanMultipleOwners
57       | ProtocolPlugin::CanConversationId;
58 }
59 
statuses() const60 unsigned long Factory::statuses() const
61 {
62   using Licq::User;
63 
64   return User::OnlineStatus
65       | User::IdleStatus
66       | User::InvisibleStatus
67       | User::AwayStatus
68       | User::OccupiedStatus;
69 }
70 
createPlugin()71 Licq::ProtocolPluginInterface* Factory::createPlugin()
72 {
73   return new CMSN;
74 }
75 
createUser(const Licq::UserId & id,bool temporary)76 Licq::User* Factory::createUser(const Licq::UserId& id, bool temporary)
77 {
78   return new User(id, temporary);
79 }
80 
createOwner(const Licq::UserId & id)81 Licq::Owner* Factory::createOwner(const Licq::UserId& id)
82 {
83   return new Owner(id);
84 }
85 
86 } // namespace LicqMsn
87 
createFactory()88 static Licq::ProtocolPluginFactory* createFactory()
89 {
90   static LicqMsn::Factory factory;
91   return &factory;
92 }
93 
destroyFactory(Licq::ProtocolPluginFactory *)94 static void destroyFactory(Licq::ProtocolPluginFactory*)
95 {
96   // Empty
97 }
98 
99 LICQ_PROTOCOL_PLUGIN_DATA(&createFactory, &destroyFactory);
100