2010-05-16 16:02:50 -05:00
|
|
|
/*
|
2011-12-03 16:38:03 -06:00
|
|
|
* Copyright 2010-2011, Pier Luigi Fiorini. All rights reserved.
|
2010-05-16 16:02:50 -05:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Andrea Anzani, andrea.anzani@gmail.com
|
|
|
|
* Pier Luigi Fiorini, pierluigi.fiorini@gmail.com
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <Bitmap.h>
|
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:33:43 -05:00
|
|
|
#include <Path.h>
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
#include <libinterface/BitmapUtils.h>
|
|
|
|
|
|
|
|
#include "CayaProtocol.h"
|
|
|
|
#include "CayaProtocolAddOn.h"
|
|
|
|
|
|
|
|
|
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:33:43 -05:00
|
|
|
CayaProtocolAddOn::CayaProtocolAddOn(image_id image, const char* path, int32 subProto)
|
2010-05-19 17:28:26 -05:00
|
|
|
:
|
|
|
|
fImage(image),
|
2010-05-16 16:02:50 -05:00
|
|
|
fPath(path),
|
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:33:43 -05:00
|
|
|
fIcon(NULL),
|
|
|
|
fProtoIndex(subProto)
|
2010-05-16 16:02:50 -05:00
|
|
|
{
|
|
|
|
_Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
status_t
|
|
|
|
CayaProtocolAddOn::InitCheck() const
|
|
|
|
{
|
|
|
|
return fStatus;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
CayaProtocolAddOn::Path() const
|
|
|
|
{
|
|
|
|
return fPath.String();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CayaProtocol*
|
|
|
|
CayaProtocolAddOn::Protocol() const
|
|
|
|
{
|
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:33:43 -05:00
|
|
|
return ProtocolAt(fProtoIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CayaProtocol*
|
|
|
|
CayaProtocolAddOn::ProtocolAt(int32 i) const
|
|
|
|
{
|
|
|
|
CayaProtocol* proto = fGetProtocol(i);
|
|
|
|
proto->SetPath(BPath(fPath.String()));
|
|
|
|
return proto;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int32
|
|
|
|
CayaProtocolAddOn::CountProtocols() const
|
|
|
|
{
|
|
|
|
return fCountProtocols();
|
2010-05-16 16:02:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
CayaProtocolAddOn::Signature() const
|
|
|
|
{
|
|
|
|
return fSignature.String();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const char*
|
|
|
|
CayaProtocolAddOn::FriendlySignature() const
|
|
|
|
{
|
|
|
|
return fFriendlySignature.String();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-22 12:05:44 -05:00
|
|
|
BBitmap*
|
|
|
|
CayaProtocolAddOn::Icon() const
|
|
|
|
{
|
|
|
|
return ReadNodeIcon(fPath, B_LARGE_ICON, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-21 15:52:33 -05:00
|
|
|
const char*
|
2021-05-22 12:05:44 -05:00
|
|
|
CayaProtocolAddOn::ProtoSignature() const
|
2021-05-21 15:52:33 -05:00
|
|
|
{
|
|
|
|
CayaProtocol* proto = Protocol();
|
|
|
|
const char* signature = proto->Signature();
|
|
|
|
delete proto;
|
|
|
|
return signature;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-05-22 12:05:44 -05:00
|
|
|
const char*
|
|
|
|
CayaProtocolAddOn::ProtoFriendlySignature() const
|
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:33:43 -05:00
|
|
|
{
|
2021-05-22 12:05:44 -05:00
|
|
|
CayaProtocol* proto = Protocol();
|
|
|
|
const char* signature = proto->FriendlySignature();
|
|
|
|
delete proto;
|
|
|
|
return signature;
|
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:33:43 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
BBitmap*
|
2021-05-22 12:05:44 -05:00
|
|
|
CayaProtocolAddOn::ProtoIcon() const
|
2010-05-16 16:02:50 -05:00
|
|
|
{
|
2021-05-22 12:05:44 -05:00
|
|
|
CayaProtocol* proto = Protocol();
|
|
|
|
BBitmap* icon = proto->Icon();
|
|
|
|
delete proto;
|
|
|
|
return icon;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32
|
|
|
|
CayaProtocolAddOn::Version() const
|
|
|
|
{
|
|
|
|
return fVersion;
|
2010-05-16 16:02:50 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
CayaProtocolAddOn::_Init()
|
|
|
|
{
|
|
|
|
const char* (*signature)();
|
|
|
|
const char* (*friendly_signature)();
|
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:33:43 -05:00
|
|
|
uint32 (*version)();
|
2010-05-16 16:02:50 -05:00
|
|
|
|
|
|
|
fStatus = B_OK;
|
|
|
|
|
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:33:43 -05:00
|
|
|
if (get_image_symbol(fImage, "protocol_at", B_SYMBOL_TYPE_TEXT,
|
2010-05-16 16:02:50 -05:00
|
|
|
(void**)&fGetProtocol) != B_OK) {
|
|
|
|
unload_add_on(fImage);
|
|
|
|
fStatus = B_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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:33:43 -05:00
|
|
|
if (get_image_symbol(fImage, "protocol_count", B_SYMBOL_TYPE_TEXT,
|
|
|
|
(void**)&fCountProtocols) != B_OK) {
|
|
|
|
unload_add_on(fImage);
|
|
|
|
fStatus = B_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
if (get_image_symbol(fImage, "signature", B_SYMBOL_TYPE_TEXT,
|
|
|
|
(void**)&signature) != B_OK) {
|
|
|
|
unload_add_on(fImage);
|
|
|
|
fStatus = B_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (get_image_symbol(fImage, "friendly_signature", B_SYMBOL_TYPE_TEXT,
|
|
|
|
(void**)&friendly_signature) != B_OK) {
|
|
|
|
unload_add_on(fImage);
|
|
|
|
fStatus = B_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
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:33:43 -05:00
|
|
|
if (get_image_symbol(fImage, "version", B_SYMBOL_TYPE_TEXT,
|
|
|
|
(void**)&version) != B_OK) {
|
|
|
|
unload_add_on(fImage);
|
|
|
|
fStatus = B_ERROR;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-05-16 16:02:50 -05:00
|
|
|
fSignature = signature();
|
|
|
|
fFriendlySignature = friendly_signature();
|
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:33:43 -05:00
|
|
|
fVersion = version();
|
2010-05-16 16:02:50 -05:00
|
|
|
}
|