Media: Add support for media services notifications
This commit is contained in:
@@ -14,7 +14,6 @@
|
|||||||
|
|
||||||
#include <Catalog.h>
|
#include <Catalog.h>
|
||||||
#include <Locale.h>
|
#include <Locale.h>
|
||||||
#include <Roster.h>
|
|
||||||
#include <StorageKit.h>
|
#include <StorageKit.h>
|
||||||
#include <String.h>
|
#include <String.h>
|
||||||
|
|
||||||
@@ -59,14 +58,6 @@ Media::Media()
|
|||||||
|
|
||||||
MediaListItem::SetIcons(&fIcons);
|
MediaListItem::SetIcons(&fIcons);
|
||||||
fWindow = new MediaWindow(rect);
|
fWindow = new MediaWindow(rect);
|
||||||
|
|
||||||
be_roster->StartWatching(BMessenger(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Media::~Media()
|
|
||||||
{
|
|
||||||
be_roster->StopWatching(BMessenger(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,22 +70,6 @@ Media::InitCheck()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
Media::MessageReceived(BMessage* message)
|
|
||||||
{
|
|
||||||
switch (message->what) {
|
|
||||||
case B_SOME_APP_LAUNCHED:
|
|
||||||
case B_SOME_APP_QUIT:
|
|
||||||
fWindow->PostMessage(message);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
BApplication::MessageReceived(message);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,9 +23,7 @@ static const char* kApplicationSignature = "application/x-vnd.Haiku-Media";
|
|||||||
class Media : public BApplication {
|
class Media : public BApplication {
|
||||||
public:
|
public:
|
||||||
Media();
|
Media();
|
||||||
virtual ~Media();
|
|
||||||
|
|
||||||
virtual void MessageReceived(BMessage* message);
|
|
||||||
status_t InitCheck();
|
status_t InitCheck();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -167,6 +167,10 @@ MediaWindow::MediaWindow(BRect frame)
|
|||||||
fInitCheck(B_OK)
|
fInitCheck(B_OK)
|
||||||
{
|
{
|
||||||
_InitWindow();
|
_InitWindow();
|
||||||
|
|
||||||
|
BMediaRoster* roster = BMediaRoster::Roster();
|
||||||
|
roster->StartWatching(BMessenger(this, this),
|
||||||
|
B_MEDIA_SERVER_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -188,6 +192,10 @@ MediaWindow::~MediaWindow()
|
|||||||
if (file.InitCheck() == B_OK)
|
if (file.InitCheck() == B_OK)
|
||||||
file.Write(buffer, strlen(buffer));
|
file.Write(buffer, strlen(buffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BMediaRoster* roster = BMediaRoster::CurrentRoster();
|
||||||
|
roster->StopWatching(BMessenger(this, this),
|
||||||
|
B_MEDIA_SERVER_STARTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -313,31 +321,12 @@ MediaWindow::MessageReceived(BMessage* message)
|
|||||||
item->AlterWindow(this);
|
item->AlterWindow(this);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case B_SOME_APP_LAUNCHED:
|
case B_MEDIA_SERVER_STARTED:
|
||||||
{
|
{
|
||||||
PRINT_OBJECT(*message);
|
PRINT_OBJECT(*message);
|
||||||
|
|
||||||
BString mimeSig;
|
_Notify(0.75, B_TRANSLATE("Starting media server"
|
||||||
if (message->FindString("be:signature", &mimeSig) == B_OK
|
B_UTF8_ELLIPSIS));
|
||||||
&& (mimeSig == "application/x-vnd.Be.addon-host"
|
|
||||||
|| mimeSig == "application/x-vnd.Be.media-server")) {
|
|
||||||
_Notify(0.75, B_TRANSLATE("Starting media server"
|
|
||||||
B_UTF8_ELLIPSIS));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case B_SOME_APP_QUIT:
|
|
||||||
{
|
|
||||||
PRINT_OBJECT(*message);
|
|
||||||
BString mimeSig;
|
|
||||||
if (message->FindString("be:signature", &mimeSig) == B_OK) {
|
|
||||||
if (mimeSig == "application/x-vnd.Be.addon-host"
|
|
||||||
|| mimeSig == "application/x-vnd.Be.media-server") {
|
|
||||||
BMediaRoster* roster = BMediaRoster::CurrentRoster();
|
|
||||||
if (roster != NULL && roster->Lock())
|
|
||||||
roster->Quit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user