123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- #include <Bitmap.h>
- #include <Path.h>
- #include <libinterface/BitmapUtils.h>
- #include "ChatProtocol.h"
- #include "ChatProtocolAddOn.h"
- ChatProtocolAddOn::ChatProtocolAddOn(image_id image, const char* path, int32 subProto)
- :
- fImage(image),
- fPath(path),
- fIcon(NULL),
- fProtoIndex(subProto)
- {
- _Init();
- }
- status_t
- ChatProtocolAddOn::InitCheck() const
- {
- return fStatus;
- }
- const char*
- ChatProtocolAddOn::Path() const
- {
- return fPath.String();
- }
- ChatProtocol*
- ChatProtocolAddOn::Protocol() const
- {
- return ProtocolAt(fProtoIndex);
- }
- ChatProtocol*
- ChatProtocolAddOn::ProtocolAt(int32 i) const
- {
- ChatProtocol* proto = fGetProtocol(i);
- proto->SetAddOnPath(BPath(fPath.String()));
- return proto;
- }
- int32
- ChatProtocolAddOn::CountProtocols() const
- {
- return fCountProtocols();
- }
- const char*
- ChatProtocolAddOn::Signature() const
- {
- return fSignature.String();
- }
- const char*
- ChatProtocolAddOn::FriendlySignature() const
- {
- return fFriendlySignature.String();
- }
- BBitmap*
- ChatProtocolAddOn::Icon() const
- {
- return ReadNodeIcon(fPath, B_LARGE_ICON, true);
- }
- const char*
- ChatProtocolAddOn::ProtoSignature() const
- {
- ChatProtocol* proto = Protocol();
- const char* signature = proto->Signature();
- delete proto;
- return signature;
- }
- const char*
- ChatProtocolAddOn::ProtoFriendlySignature() const
- {
- ChatProtocol* proto = Protocol();
- const char* signature = proto->FriendlySignature();
- delete proto;
- return signature;
- }
- BBitmap*
- ChatProtocolAddOn::ProtoIcon() const
- {
- ChatProtocol* proto = Protocol();
- BBitmap* icon = proto->Icon();
- delete proto;
- return icon;
- }
- uint32
- ChatProtocolAddOn::Version() const
- {
- return fVersion;
- }
- void
- ChatProtocolAddOn::_Init()
- {
- const char* (*signature)();
- const char* (*friendly_signature)();
- uint32 (*version)();
- fStatus = B_OK;
- if (get_image_symbol(fImage, "protocol_at", B_SYMBOL_TYPE_TEXT,
- (void**)&fGetProtocol) != B_OK) {
- unload_add_on(fImage);
- fStatus = B_ERROR;
- return;
- }
- if (get_image_symbol(fImage, "protocol_count", B_SYMBOL_TYPE_TEXT,
- (void**)&fCountProtocols) != B_OK) {
- unload_add_on(fImage);
- fStatus = B_ERROR;
- return;
- }
- 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;
- }
- if (get_image_symbol(fImage, "version", B_SYMBOL_TYPE_TEXT,
- (void**)&version) != B_OK) {
- unload_add_on(fImage);
- fStatus = B_ERROR;
- return;
- }
- fSignature = signature();
- fFriendlySignature = friendly_signature();
- fVersion = version();
- }
|