void MediaWindow::MessageReceived(BMessage* message) { switch (message->what) { case ML_RESTART_THREAD_FINISHED: fRestartThread = -1; _InitMedia(false); break; case ML_RESTART_MEDIA_SERVER: { fRestartThread = spawn_thread(&MediaWindow::_RestartMediaServices, "restart_thread", B_NORMAL_PRIORITY, this); if (fRestartThread < 0) fprintf(stderr, "couldn't create restart thread\n"); else resume_thread(fRestartThread); break; } case B_MEDIA_WEB_CHANGED: case ML_SELECTED_NODE: { PRINT_OBJECT(*message); MediaListItem* item = static_cast<MediaListItem*>( fListView->ItemAt(fListView->CurrentSelection())); if (item == NULL) break; fCurrentNode.SetTo(NULL); _ClearParamView(); item->AlterWindow(this); break; } case B_MEDIA_SERVER_STARTED: case B_MEDIA_SERVER_QUIT: { PRINT_OBJECT(*message); _InitMedia(false); break; } default: BWindow::MessageReceived(message); break; } }
void NavigatorEditor::MessageReceived(BMessage *message) { TRACE(); PRINT_OBJECT(*message); switch(message->what) { case P_C_VALUE_CHANGED: { ValueChanged(); break; } case N_A_INVOKATION: { BListView *source = NULL; if (message->FindPointer("ListView",(void **) &source) == B_OK) InsertNewList(source); break; } case P_C_EDITOR_SWITCHED_ACTIV: { ValueChanged(); } default: BView::MessageReceived(message); break; } }
MediaWindow::~MediaWindow() { _EmptyNodeLists(); _ClearParamView(); char buffer[512]; BRect rect = Frame(); PRINT_OBJECT(rect); snprintf(buffer, 512, "# MediaPrefs Settings\n rect = %i,%i,%i,%i\n", int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(SETTINGS_FILE); BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() == B_OK) file.Write(buffer, strlen(buffer)); } BMediaRoster* roster = BMediaRoster::CurrentRoster(); roster->StopWatching(BMessenger(this, this), B_MEDIA_SERVER_STARTED); roster->StartWatching(BMessenger(this, this), B_MEDIA_SERVER_QUIT); }
BMessage* Copy::Do(PDocument *doc, BMessage *settings) { BMessage *clip = NULL; BMessage *node = NULL; BMessage *from = NULL; BMessage *to = NULL; bool fselect = false; bool tselect = false; BMessage *copyMessage = new BMessage(); BList *selected = doc->GetSelected(); BList *allConnections = doc->GetAllConnections(); int32 i = 0; Indexer *indexer = new Indexer(doc); if (doc->Lock()) { for (i=0;i<selected->CountItems();i++) { if (node=(BMessage *)selected->ItemAt(i)) { if (node->what != P_C_CONNECTION_TYPE) copyMessage->AddMessage("node",indexer->IndexNode(node)); } } for (i=0;i<allConnections->CountItems();i++ ) { node = (BMessage *)allConnections->ItemAt(i); if ( (node->FindPointer("From",(void **)&from) == B_OK) && (node->FindPointer("To",(void **)&to) == B_OK) ) { if ((from->FindBool("selected",&fselect)==B_OK) && (to->FindBool("selected",&tselect) == B_OK) ) { if (fselect && tselect) copyMessage->AddMessage("node",indexer->IndexConnection(node,true)); else if (fselect || tselect) copyMessage->AddMessage("node",indexer->IndexConnection(node)); } } } doc->Unlock(); } if (be_clipboard->Lock()) { be_clipboard->Clear(); if (clip = be_clipboard->Data()) { clip->AddData("application/x-vnd.projectconceptor-document", B_MIME_TYPE, copyMessage, sizeof(copyMessage)); clip->AddMessage("test",copyMessage); PRINT_OBJECT(*clip); be_clipboard->Commit(); } be_clipboard->Unlock(); } settings = PCommand::Do(doc,settings); return settings; }
//! Load the flattened settings BMessage from disk and parse it. bool ScreenSaverSettings::Load() { BFile file(fSettingsPath.Path(), B_READ_ONLY); if (file.InitCheck() != B_OK) return false; // File exists. Unflatten the message and call the settings parser. if (fSettings.Unflatten(&file) != B_OK) return false; PRINT_OBJECT(fSettings); BRect rect; if (fSettings.FindRect("windowframe", &rect) == B_OK) fWindowFrame = rect; int32 value; if (fSettings.FindInt32("windowtab", &value) == B_OK) fWindowTab = value; if (fSettings.FindInt32("timeflags", &value) == B_OK) fTimeFlags = value; if (fSettings.FindInt32("timefade", &value) == B_OK) fBlankTime = value * 1000000LL; if (fSettings.FindInt32("timestandby", &value) == B_OK) fStandByTime = value * 1000000LL; if (fSettings.FindInt32("timesuspend", &value) == B_OK) fSuspendTime = value * 1000000LL; if (fSettings.FindInt32("timeoff", &value) == B_OK) fOffTime = value * 1000000LL; if (fSettings.FindInt32("cornernow", &value) == B_OK) fBlankCorner = (screen_corner)value; if (fSettings.FindInt32("cornernever", &value) == B_OK) fNeverBlankCorner = (screen_corner)value; bool lockEnabled; if (fSettings.FindBool("lockenable", &lockEnabled) == B_OK) fLockEnabled = lockEnabled; if (fSettings.FindInt32("lockdelay", &value) == B_OK) fPasswordTime = value * 1000000LL; const char* string; if (fSettings.FindString("lockpassword", &string) == B_OK) fPassword = string; if (fSettings.FindString("lockmethod", &string) == B_OK) fLockMethod = string; if (fSettings.FindString("modulename", &string) == B_OK) fModuleName = string; if (IsNetworkPassword()) { // TODO: this does not work yet } return true; }
BMessage* Paste::Do(PDocument *doc, BMessage *settings) { BMessage *clip = NULL; BMessage *node = new BMessage(); BMessage *deIndexedNode = NULL; BMessage *connect = NULL; bool connectselect = false; BMessage *copyMessage = new BMessage; int32 messagelen = 0; int32 i = 0; Indexer *indexer = new Indexer(doc); if (be_clipboard->Lock()) { if (clip = be_clipboard->Data()) { // clip->FindData("application/x-vnd.projectconceptor-document", B_MIME_TYPE, (const void **)©Message, &messagelen); clip->FindMessage("test",copyMessage); copyMessage->PrintToStream(); } be_clipboard->Unlock(); } if (copyMessage) { BMessage *inserter = new BMessage(P_C_EXECUTE_COMMAND); BMessage *select = new BMessage(P_C_EXECUTE_COMMAND); inserter->AddString("Command::Name","Insert"); select->AddString("Command::Name","Select"); while (copyMessage->FindMessage("node",i,node) == B_OK) { if (node->what == P_C_CONNECTION_TYPE) deIndexedNode = indexer->DeIndexConnection(node); else { deIndexedNode = indexer->RegisterDeIndexNode(node); //only select nodes.. because es the copy and paste funktion with selected nodes dosent work proper select->AddPointer("node",deIndexedNode); } inserter->AddPointer("node",deIndexedNode); i++; node = new BMessage(); } i=0; while (inserter->FindPointer("node",i,(void **)&node) == B_OK) { if (node->what != P_C_CONNECTION_TYPE) indexer->DeIndexNode(node); i++; } inserter->AddMessage("PCommand::subPCommand",select); PRINT_OBJECT(*inserter); (new BMessenger(NULL,doc))->SendMessage(inserter); } return settings; }
void ScreenSaverSettings::Save() { BMessage &settings = Message(); PRINT_OBJECT(settings); BFile file(fSettingsPath.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() != B_OK || settings.Flatten(&file) != B_OK) fprintf(stderr, "Problem while saving screensaver preferences file!\n"); }
void Settings::PrintToStream() { PRINT(("\n")); PRINT(("\tENCODER NAME = %s\n", encoderName)); PRINT(("\tADD_ON_DIR = %s\n", addonDirectory)); PRINT(("\tPATH_PATTERN = %s\n", pathPattern)); PRINT(("\tIS_ENCODING = %s\n", encoding)); PRINT_OBJECT(columnsState); }
MediaWindow::~MediaWindow() { _EmptyNodeLists(); _ClearParamView(); char buffer[512]; BRect rect = Frame(); PRINT_OBJECT(rect); snprintf(buffer, 512, "# MediaPrefs Settings\n rect = %i,%i,%i,%i\n", int(rect.left), int(rect.top), int(rect.right), int(rect.bottom)); BPath path; if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) == B_OK) { path.Append(SETTINGS_FILE); BFile file(path.Path(), B_READ_WRITE | B_CREATE_FILE | B_ERASE_FILE); if (file.InitCheck() == B_OK) file.Write(buffer, strlen(buffer)); } }
void AutoMounter::MessageReceived(BMessage *message) { switch (message->what) { #if _INCLUDES_CLASS_DEVICE_MAP case kAutomounterRescan: RescanDevices(); break; case kStartPolling: // PRINT(("starting the automounter\n")); fScanThread = spawn_thread(AutoMounter::WatchVolumeBinder, #if DEBUG "HiroshiLikesAtomountScan", // long story #else "AutomountScan", #endif B_LOW_PRIORITY, this); resume_thread(fScanThread); break; case kMountVolume: MountVolume(message); break; case kUnmountVolume: UnmountAndEjectVolume(message); break; case kSetAutomounterParams: { bool rescanNow = false; message->FindBool("rescanNow", &rescanNow); SetParams(message, rescanNow); WriteSettings(); break; } case kMountAllNow: RescanDevices(); MountAllNow(); break; case kSuspendAutomounter: SuspendResume(true); break; case kResumeAutomounter: SuspendResume(false); break; case kTryMountingFloppy: TryMountingFloppy(); break; case B_NODE_MONITOR: { int32 opcode; if (message->FindInt32("opcode", &opcode) != B_OK) break; switch (opcode) { case B_DEVICE_MOUNTED: { WRITELOG(("** Received Device Mounted Notification")); dev_t device; if (message->FindInt32("new device", &device) == B_OK) { Partition *partition = FindPartition(device); if (partition == NULL || partition->Mounted() != kMounted) { WRITELOG(("Device %i not in device list. Someone mounted it outside " "of Tracker", device)); // // This is the worst case. Someone has mounted // something from outside of tracker. // Unfortunately, there's no easy way to tell which // partition was just mounted (or if we even know about the device), // so stop watching all nodes, rescan to see what is now mounted, // and start watching again. // RescanDevices(); } else WRITELOG(("Found partition\n")); } else { WRITELOG(("ERROR: Could not find mounted device ID in message")); PRINT_OBJECT(*message); } break; } case B_DEVICE_UNMOUNTED: { WRITELOG(("*** Received Device Unmounted Notification")); dev_t device; if (message->FindInt32("device", &device) == B_OK) { Partition *partition = FindPartition(device); if (partition != 0) { WRITELOG(("Found device in device list. Updating state to unmounted.")); partition->SetMountState(kNotMounted); } else WRITELOG(("Unmounted device %i was not in device list", device)); } else { WRITELOG(("ERROR: Could not find unmounted device ID in message")); PRINT_OBJECT(*message); } break; } // The name of a mount point has changed case B_ENTRY_MOVED: { WRITELOG(("*** Received Mount Point Renamed Notification")); const char *newName; if (message->FindString("name", &newName) != B_OK) { WRITELOG(("ERROR: Couldn't find name field in update message")); PRINT_OBJECT(*message); break ; } // // When the node monitor reports a move, it gives the // parent device and inode that moved. The problem is // that the inode is the inode of root *in* the filesystem, // which is generally always the same number for every // filesystem of a type. // // What we'd really like is the device that the moved // volume is mounted on. Find this by using the // *new* name and directory, and then stat()ing that to // find the device. // dev_t parentDevice; if (message->FindInt32("device", &parentDevice) != B_OK) { WRITELOG(("ERROR: Couldn't find 'device' field in update" " message")); PRINT_OBJECT(*message); break; } ino_t toDirectory; if (message->FindInt64("to directory", &toDirectory)!=B_OK){ WRITELOG(("ERROR: Couldn't find 'to directory' field in update" "message")); PRINT_OBJECT(*message); break; } entry_ref root_entry(parentDevice, toDirectory, newName); BNode entryNode(&root_entry); if (entryNode.InitCheck() != B_OK) { WRITELOG(("ERROR: Couldn't create mount point entry node: %s/n", strerror(entryNode.InitCheck()))); break; } node_ref mountPointNode; if (entryNode.GetNodeRef(&mountPointNode) != B_OK) { WRITELOG(("ERROR: Couldn't get node ref for new mount point")); break; } WRITELOG(("Attempt to rename device %li to %s", mountPointNode.device, newName)); Partition *partition = FindPartition(mountPointNode.device); if (partition != NULL) { WRITELOG(("Found device, changing name.")); BVolume mountVolume(partition->VolumeDeviceID()); BDirectory mountDir; mountVolume.GetRootDirectory(&mountDir); BPath dirPath(&mountDir, 0); partition->SetMountedAt(dirPath.Path()); partition->SetVolumeName(newName); break; } else WRITELOG(("ERROR: Device %li does not appear to be present", mountPointNode.device)); } } } break; #endif default: BLooper::MessageReceived(message); break; } }
void AutoMounter::MessageReceived(BMessage* message) { switch (message->what) { case kMountVolume: _MountVolume(message); break; case kUnmountVolume: _UnmountAndEjectVolume(message); break; case kSetAutomounterParams: { bool rescanNow = false; message->FindBool("rescanNow", &rescanNow); _UpdateSettingsFromMessage(message); _GetSettings(&fSettings); _WriteSettings(); if (rescanNow) _MountVolumes(fNormalMode, fRemovableMode); break; } case kGetAutomounterParams: { BMessage reply; _GetSettings(&reply); message->SendReply(&reply); break; } case kMountAllNow: _MountVolumes(kAllVolumes, kAllVolumes); break; case B_DEVICE_UPDATE: int32 event; if (message->FindInt32("event", &event) != B_OK || (event != B_DEVICE_MEDIA_CHANGED && event != B_DEVICE_ADDED)) break; partition_id deviceID; if (message->FindInt32("id", &deviceID) != B_OK) break; _MountVolumes(kNoVolumes, fRemovableMode, false, deviceID); break; #if 0 case B_NODE_MONITOR: { int32 opcode; if (message->FindInt32("opcode", &opcode) != B_OK) break; switch (opcode) { // The name of a mount point has changed case B_ENTRY_MOVED: { WRITELOG(("*** Received Mount Point Renamed Notification")); const char *newName; if (message->FindString("name", &newName) != B_OK) { WRITELOG(("ERROR: Couldn't find name field in update " "message")); PRINT_OBJECT(*message); break ; } // // When the node monitor reports a move, it gives the // parent device and inode that moved. The problem is // that the inode is the inode of root *in* the filesystem, // which is generally always the same number for every // filesystem of a type. // // What we'd really like is the device that the moved // volume is mounted on. Find this by using the // *new* name and directory, and then stat()ing that to // find the device. // dev_t parentDevice; if (message->FindInt32("device", &parentDevice) != B_OK) { WRITELOG(("ERROR: Couldn't find 'device' field in " "update message")); PRINT_OBJECT(*message); break; } ino_t toDirectory; if (message->FindInt64("to directory", &toDirectory) != B_OK) { WRITELOG(("ERROR: Couldn't find 'to directory' field " "in update message")); PRINT_OBJECT(*message); break; } entry_ref root_entry(parentDevice, toDirectory, newName); BNode entryNode(&root_entry); if (entryNode.InitCheck() != B_OK) { WRITELOG(("ERROR: Couldn't create mount point entry " "node: %s/n", strerror(entryNode.InitCheck()))); break; } node_ref mountPointNode; if (entryNode.GetNodeRef(&mountPointNode) != B_OK) { WRITELOG(("ERROR: Couldn't get node ref for new mount " "point")); break; } WRITELOG(("Attempt to rename device %li to %s", mountPointNode.device, newName)); Partition *partition = FindPartition(mountPointNode.device); if (partition != NULL) { WRITELOG(("Found device, changing name.")); BVolume mountVolume(partition->VolumeDeviceID()); BDirectory mountDir; mountVolume.GetRootDirectory(&mountDir); BPath dirPath(&mountDir, 0); partition->SetMountedAt(dirPath.Path()); partition->SetVolumeName(newName); break; } else { WRITELOG(("ERROR: Device %li does not appear to be " "present", mountPointNode.device)); } } } break; } #endif default: BLooper::MessageReceived(message); break; } }
void MediaWindow::MessageReceived(BMessage* message) { switch (message->what) { case ML_INIT_MEDIA: _InitMedia(false); break; case ML_RESTART_MEDIA_SERVER: { thread_id thread = spawn_thread(&MediaWindow::_RestartMediaServices, "restart_thread", B_NORMAL_PRIORITY, this); if (thread < 0) fprintf(stderr, "couldn't create restart thread\n"); else resume_thread(thread); break; } case B_MEDIA_WEB_CHANGED: case ML_SELECTED_NODE: { PRINT_OBJECT(*message); MediaListItem* item = static_cast<MediaListItem*>( fListView->ItemAt(fListView->CurrentSelection())); if (item == NULL) break; fCurrentNode.SetTo(NULL); _ClearParamView(); item->AlterWindow(this); break; } case B_SOME_APP_LAUNCHED: { PRINT_OBJECT(*message); BString mimeSig; if (message->FindString("be:signature", &mimeSig) == B_OK && (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; } default: BWindow::MessageReceived(message); break; } }