1 /*
2 * This file is part of Licq, an instant messaging client for UNIX.
3 * Copyright (C) 2010-2014 Licq developers <licq-dev@googlegroups.com>
4 *
5 * Please refer to the COPYRIGHT file distributed with this source
6 * distribution for the names of the individual contributors.
7 *
8 * Licq is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * Licq is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with Licq; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22
23 #include <licq/plugin/protocolplugin.h>
24 #include <licq/plugin/protocolpluginfactory.h>
25 #include <licq/version.h>
26
27 #include "owner.h"
28 #include "plugin.h"
29 #include "pluginversion.h"
30 #include "user.h"
31
32 namespace LicqJabber
33 {
34
35 class Factory : public Licq::ProtocolPluginFactory
36 {
37 public:
38 // From Licq::PluginFactory
name() const39 std::string name() const { return "Jabber"; }
version() const40 std::string version() const { return PLUGIN_VERSION_STRING; }
destroyPlugin(Licq::PluginInterface * plugin)41 void destroyPlugin(Licq::PluginInterface* plugin) { delete plugin; }
42
43 // From Licq::ProtocolPluginFactory
protocolId() const44 unsigned long protocolId() const { return JABBER_PPID; }
45 unsigned long capabilities() const;
46 unsigned long statuses() const;
47 Licq::ProtocolPluginInterface* createPlugin();
48 Licq::User* createUser(const Licq::UserId& id, bool temporary);
49 Licq::Owner* createOwner(const Licq::UserId& id);
50 };
51
capabilities() const52 unsigned long Factory::capabilities() const
53 {
54 using Licq::ProtocolPlugin;
55
56 return ProtocolPlugin::CanSendMsg
57 | ProtocolPlugin::CanHoldStatusMsg
58 | ProtocolPlugin::CanSendAuth
59 | ProtocolPlugin::CanSendAuthReq
60 | ProtocolPlugin::CanMultipleOwners;
61 }
62
statuses() const63 unsigned long Factory::statuses() const
64 {
65 using Licq::User;
66
67 return User::OnlineStatus
68 | User::IdleStatus
69 | User::InvisibleStatus
70 | User::AwayStatus
71 | User::NotAvailableStatus
72 | User::DoNotDisturbStatus
73 | User::FreeForChatStatus;
74 }
75
createPlugin()76 Licq::ProtocolPluginInterface* Factory::createPlugin()
77 {
78 return new Plugin;
79 }
80
createUser(const Licq::UserId & id,bool temporary)81 Licq::User* Factory::createUser(const Licq::UserId& id, bool temporary)
82 {
83 return new User(id, temporary);
84 }
85
createOwner(const Licq::UserId & id)86 Licq::Owner* Factory::createOwner(const Licq::UserId& id)
87 {
88 return new Owner(id);
89 }
90
91 } // namespace LicqJabber
92
createFactory()93 static Licq::ProtocolPluginFactory* createFactory()
94 {
95 static LicqJabber::Factory factory;
96 return &factory;
97 }
98
destroyFactory(Licq::ProtocolPluginFactory *)99 static void destroyFactory(Licq::ProtocolPluginFactory*)
100 {
101 // Empty
102 }
103
104 LICQ_PROTOCOL_PLUGIN_DATA(&createFactory, &destroyFactory);
105