Chat-O-Matic/protocols/xmpp/GoogleTalkProtocol.cpp
Jaidyn Ann 61a1f0baf1 Allow multiple protocols per add-on
Now an add-on can contain multiple protocols, and the protocol API has
changed. An add-on must now export protocol_count() and protocol_at(),
with the latter replacing protocol(). protocol_count() returning the
amount of protocols in a given add-on, and protocol_at(i) giving a
new CayaProtocol* "at" the given index.

CayaProtocol has also been changed, adding Signature(),
FriendlySignature(), Icon(), Path(), and SetPath(). The reasoning is
that different protocols (even within a single add-on) will have
different signatures and icons, so this data should be accessible from
the protocol itself.

CayaProtocolAddOn now has CountProtocols() and ProtocolAt(i), allowing
the accessing of multiple protocols. A CayaProtocolAddOn can be given a
default protocol index in the constructor, whose protocol will be
returned with Protocol(). Version() was also moved from CayaProtocol to
CayaProtocolAddOn.
2021-05-21 13:47:14 -05:00

73 lines
1.0 KiB
C++

/*
* Copyright 2010, Pier Luigi Fiorini. All rights reserved.
* Distributed under the terms of the GPL v2 License.
*
* Authors:
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
*/
#include "GoogleTalkProtocol.h"
#include <Resources.h>
#include <libinterface/BitmapUtils.h>
GoogleTalkProtocol::GoogleTalkProtocol()
: JabberHandler()
{
}
GoogleTalkProtocol::~GoogleTalkProtocol()
{
}
const char*
GoogleTalkProtocol::Signature() const
{
return "gtalk";
}
const char*
GoogleTalkProtocol::FriendlySignature() const
{
return "GTalk";
}
BBitmap*
GoogleTalkProtocol::Icon() const
{
BResources res(fPath.Path());
return IconFromResources(&res, 2, B_LARGE_ICON);
}
BMessage
GoogleTalkProtocol::SettingsTemplate()
{
return JabberHandler::_SettingsTemplate("Identifier", false);
}
void
GoogleTalkProtocol::OverrideSettings()
{
fServer = "talk.google.com";
fPort = 0;
}
BString
GoogleTalkProtocol::ComposeJID() const
{
BString jid(fUsername);
if (jid.FindLast("@") < 0)
jid << "@gmail.com";
jid << "/" << fResource;
return jid;
}