Show protocol icons in notifications
CayaProtocolAddOn now has the convenience functions ProtoIcon(), ProtoSignature(), and ProtoFriendlySignature(), for getting info from its default protocol.
This commit is contained in:
parent
6ca134f9f6
commit
4705d586f9
|
@ -78,8 +78,15 @@ CayaProtocolAddOn::FriendlySignature() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BBitmap*
|
||||||
|
CayaProtocolAddOn::Icon() const
|
||||||
|
{
|
||||||
|
return ReadNodeIcon(fPath, B_LARGE_ICON, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const char*
|
const char*
|
||||||
CayaProtocolAddOn::SubSignature() const
|
CayaProtocolAddOn::ProtoSignature() const
|
||||||
{
|
{
|
||||||
CayaProtocol* proto = Protocol();
|
CayaProtocol* proto = Protocol();
|
||||||
const char* signature = proto->Signature();
|
const char* signature = proto->Signature();
|
||||||
|
@ -88,17 +95,30 @@ CayaProtocolAddOn::SubSignature() const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32
|
const char*
|
||||||
CayaProtocolAddOn::Version() const
|
CayaProtocolAddOn::ProtoFriendlySignature() const
|
||||||
{
|
{
|
||||||
return fVersion;
|
CayaProtocol* proto = Protocol();
|
||||||
|
const char* signature = proto->FriendlySignature();
|
||||||
|
delete proto;
|
||||||
|
return signature;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BBitmap*
|
BBitmap*
|
||||||
CayaProtocolAddOn::Icon() const
|
CayaProtocolAddOn::ProtoIcon() const
|
||||||
{
|
{
|
||||||
return ReadNodeIcon(fPath, B_LARGE_ICON, true);
|
CayaProtocol* proto = Protocol();
|
||||||
|
BBitmap* icon = proto->Icon();
|
||||||
|
delete proto;
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32
|
||||||
|
CayaProtocolAddOn::Version() const
|
||||||
|
{
|
||||||
|
return fVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,11 +29,14 @@ public:
|
||||||
|
|
||||||
const char* Signature() const;
|
const char* Signature() const;
|
||||||
const char* FriendlySignature() const;
|
const char* FriendlySignature() const;
|
||||||
const char* SubSignature() const;
|
|
||||||
uint32 Version() const;
|
|
||||||
|
|
||||||
BBitmap* Icon() const;
|
BBitmap* Icon() const;
|
||||||
|
|
||||||
|
const char* ProtoSignature() const;
|
||||||
|
const char* ProtoFriendlySignature() const;
|
||||||
|
BBitmap* ProtoIcon() const;
|
||||||
|
|
||||||
|
uint32 Version() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
image_id fImage;
|
image_id fImage;
|
||||||
BString fPath;
|
BString fPath;
|
||||||
|
|
|
@ -75,7 +75,7 @@ ProtocolSettings::Accounts() const
|
||||||
{
|
{
|
||||||
BObjectList<BString> list(true);
|
BObjectList<BString> list(true);
|
||||||
|
|
||||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->ProtoSignature()));
|
||||||
if (path.InitCheck() != B_OK)
|
if (path.InitCheck() != B_OK)
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ ProtocolSettings::Rename(const char* from, const char* to)
|
||||||
status_t ret = B_ERROR;
|
status_t ret = B_ERROR;
|
||||||
|
|
||||||
// Find user's settings path
|
// Find user's settings path
|
||||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->ProtoSignature()));
|
||||||
if ((ret = path.InitCheck()) != B_OK)
|
if ((ret = path.InitCheck()) != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -382,7 +382,7 @@ ProtocolSettings::Delete(const char* account)
|
||||||
status_t ret = B_ERROR;
|
status_t ret = B_ERROR;
|
||||||
|
|
||||||
// Find user's settings path
|
// Find user's settings path
|
||||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->ProtoSignature()));
|
||||||
if ((ret = path.InitCheck()) != B_OK)
|
if ((ret = path.InitCheck()) != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -417,7 +417,7 @@ ProtocolSettings::_Load(const char* account, BMessage** settings)
|
||||||
status_t ret = B_ERROR;
|
status_t ret = B_ERROR;
|
||||||
|
|
||||||
// Find user's settings path
|
// Find user's settings path
|
||||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->ProtoSignature()));
|
||||||
if ((ret = path.InitCheck()) != B_OK)
|
if ((ret = path.InitCheck()) != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ ProtocolSettings::_Save(const char* account, BMessage* settings)
|
||||||
status_t ret = B_ERROR;
|
status_t ret = B_ERROR;
|
||||||
|
|
||||||
// Find user's settings path
|
// Find user's settings path
|
||||||
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->SubSignature()));
|
BPath path(CayaAccountPath(fAddOn->Signature(), fAddOn->ProtoSignature()));
|
||||||
if ((ret = path.InitCheck()) != B_OK)
|
if ((ret = path.InitCheck()) != B_OK)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ Server::ImMessage(BMessage* msg)
|
||||||
BNotification notification(B_PROGRESS_NOTIFICATION);
|
BNotification notification(B_PROGRESS_NOTIFICATION);
|
||||||
notification.SetGroup(BString("Caya"));
|
notification.SetGroup(BString("Caya"));
|
||||||
notification.SetTitle(title);
|
notification.SetTitle(title);
|
||||||
notification.SetIcon(addOn->Icon());
|
notification.SetIcon(addOn->ProtoIcon());
|
||||||
notification.SetContent(message);
|
notification.SetContent(message);
|
||||||
notification.SetProgress(progress);
|
notification.SetProgress(progress);
|
||||||
notification.Send();
|
notification.Send();
|
||||||
|
@ -402,7 +402,7 @@ Server::ImMessage(BMessage* msg)
|
||||||
BNotification notification((notification_type)type);
|
BNotification notification((notification_type)type);
|
||||||
notification.SetGroup(BString("Caya"));
|
notification.SetGroup(BString("Caya"));
|
||||||
notification.SetTitle(title);
|
notification.SetTitle(title);
|
||||||
notification.SetIcon(addOn->Icon());
|
notification.SetIcon(addOn->ProtoIcon());
|
||||||
notification.SetContent(message);
|
notification.SetContent(message);
|
||||||
notification.Send();
|
notification.Send();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,6 @@ PreferencesAccounts::PreferencesAccounts()
|
||||||
fProtosMenu = new BPopUpMenu(NULL, true);
|
fProtosMenu = new BPopUpMenu(NULL, true);
|
||||||
for (uint32 i = 0; i < pm->CountProtocolAddOns(); i++) {
|
for (uint32 i = 0; i < pm->CountProtocolAddOns(); i++) {
|
||||||
CayaProtocolAddOn* addOn = pm->ProtocolAddOnAt(i);
|
CayaProtocolAddOn* addOn = pm->ProtocolAddOnAt(i);
|
||||||
CayaProtocol* proto = addOn->Protocol();
|
|
||||||
ProtocolSettings* settings = new ProtocolSettings(addOn);
|
ProtocolSettings* settings = new ProtocolSettings(addOn);
|
||||||
|
|
||||||
// Add accounts to list view
|
// Add accounts to list view
|
||||||
|
@ -68,9 +67,8 @@ PreferencesAccounts::PreferencesAccounts()
|
||||||
msg->AddPointer("settings", settings);
|
msg->AddPointer("settings", settings);
|
||||||
|
|
||||||
BitmapMenuItem* item = new BitmapMenuItem(
|
BitmapMenuItem* item = new BitmapMenuItem(
|
||||||
proto->FriendlySignature(), msg, proto->Icon());
|
addOn->ProtoFriendlySignature(), msg, addOn->ProtoIcon());
|
||||||
fProtosMenu->AddItem(item);
|
fProtosMenu->AddItem(item);
|
||||||
delete proto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ToolButton* proto = new ToolButton("Add", NULL);
|
ToolButton* proto = new ToolButton("Add", NULL);
|
||||||
|
|
Ŝarĝante…
Reference in New Issue