本文整理汇总了C++中BFilePanel::Window方法的典型用法代码示例。如果您正苦于以下问题:C++ BFilePanel::Window方法的具体用法?C++ BFilePanel::Window怎么用?C++ BFilePanel::Window使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFilePanel
的用法示例。
在下文中一共展示了BFilePanel::Window方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
filter_result
DCCFileFilter::HandleButton (BMessage *)
{
filter_result result (B_DISPATCH_MESSAGE);
BTextControl *paneltext (dynamic_cast<BTextControl *>(
panel->Window()->FindView ("text view")));
if (paneltext)
{
BDirectory dir;
struct stat s;
entry_ref ref;
BEntry entry;
panel->GetPanelDirectory (&ref);
dir.SetTo (&ref);
if (entry.SetTo (&dir, paneltext->Text()) == B_NO_ERROR
&& entry.GetStat (&s) == B_NO_ERROR
&& S_ISREG (s.st_mode))
{
if (vision_app->GetBool ("dccAutoAccept"))
{
BMessage msg (M_FILE_PANEL_ALERT);
msg.AddInt32 ("which", 2);
panel->Window()->PostMessage (&msg);
result = B_SKIP_MESSAGE;
}
else
{
BString buffer;
BAlert *alert;
buffer << "The file \""
<< paneltext->Text()
<< "\" already exists in the specified folder. "
"Do you want to continue the transfer?";
alert = new BAlert (
"DCC Request",
buffer.String(),
"Cancel",
"Replace",
"Resume",
B_WIDTH_AS_USUAL,
B_OFFSET_SPACING,
B_WARNING_ALERT);
alert->Go (new BInvoker (
new BMessage (M_FILE_PANEL_ALERT),
panel->Window()));
result = B_SKIP_MESSAGE;
}
}
}
return result;
}
示例2: TemplateLooper
char *run_template_selector(BMessage msg_to_deliver, BMessenger target)
{
TemplateLooper *looper;
BMessenger *messenger;
BFilePanel *panel;
BMessage *msg;
// create looper to deliver it to
looper = new TemplateLooper();
looper->Run();
messenger = new BMessenger(NULL, looper);
msg = new BMessage(M_TEMPLATE_SELECT);
msg->AddMessage("message", &msg_to_deliver);
msg->AddMessenger("target", target);
// set starting dir to that of template directory
entry_ref start_dir;
GetTemplateDirectoryRef(&start_dir);
// create panel
panel = new BFilePanel(B_OPEN_PANEL, messenger, &start_dir, 0, false, msg, NULL, true);
panel->Window()->SetTitle("Select Template");
// and away we go
if (TemplatePanel) delete TemplatePanel;
TemplatePanel = panel;
panel->Show();
}
示例3: run_template_loader
void run_template_loader()
{
TemplateLooper *looper;
BMessenger *messenger;
BFilePanel *panel;
// create looper to deliver it to
looper = new TemplateLooper();
looper->Run();
messenger = new BMessenger(NULL, looper);
// set starting dir to that of template directory
entry_ref start_dir;
GetTemplateDirectoryRef(&start_dir);
// create panel
panel = new BFilePanel(B_OPEN_PANEL, messenger, &start_dir, 0, true, new BMessage(M_TEMPLATE_LOAD), NULL, true);
panel->Window()->SetTitle("New from Template");
// and away we go
if (TemplatePanel) delete TemplatePanel;
TemplatePanel = panel;
panel->Show();
}
示例4: run_template_saver
// pop up the Save box for a template, and have it save a copy of the current document.
void run_template_saver()
{
TemplateLooper *looper;
BMessage *message;
BMessenger *messenger;
BFilePanel *panel;
// create message to deliver when done
message = new BMessage(M_TEMPLATE_SAVE);
message->AddInt32("DocID", editor.curev->DocID);
// create looper to deliver it to
looper = new TemplateLooper();
looper->Run();
messenger = new BMessenger(NULL, looper);
// set starting dir to that of template directory
entry_ref start_dir;
GetTemplateDirectoryRef(&start_dir);
// create panel
panel = new BFilePanel(B_SAVE_PANEL, messenger, &start_dir, 0, false, message, NULL, true);
// set window title
BString title;
title << "Save as Template: " << GetFileSpec(editor.curev->filename);
panel->Window()->SetTitle(title.String());
// and away we go
if (TemplatePanel) delete TemplatePanel;
TemplatePanel = panel;
panel->Show();
}
示例5: getMountFolder
// getMountFolder()
//
void getMountFolder()
{
char path[B_PATH_NAME_LENGTH];
entry_ref entryRef;
find_directory(B_USER_DIRECTORY, 0, false, path, sizeof(path));
BEntry entry(path, false);
entry.GetRef(&entryRef);
BFilePanel *filePanel = new BFilePanel(B_OPEN_PANEL, &be_app_messenger, &entryRef, B_DIRECTORY_NODE, false);
filePanel->Show();
filePanel->Window()->SetTitle("Mount Location");
filePanel->SetButtonLabel(B_DEFAULT_BUTTON, "Mount");
}
示例6: dir
filter_result
DCCFileFilter::HandleAlert (BMessage *msg)
{
BTextControl *text (dynamic_cast<BTextControl *>(
panel->Window()->FindView ("text view")));
int32 which;
msg->FindInt32 ("which", &which);
if (which == 0 || text == 0)
{
return B_SKIP_MESSAGE;
}
entry_ref ref;
panel->GetPanelDirectory (&ref);
if (which == 2)
{
BDirectory dir (&ref);
BFile file (&dir, text->Text(), B_READ_ONLY);
BEntry entry (&dir, text->Text());
BPath path;
off_t position;
file.GetSize (&position);
entry.GetPath (&path);
send_msg.AddString ("path", path.Path());
send_msg.AddInt64 ("pos", position);
send_msg.what = M_ADD_RESUME_DATA;
}
else
{
send_msg.AddRef ("directory", &ref);
send_msg.AddString ("name", text->Text());
}
panel->Messenger().SendMessage (&send_msg);
BMessage cmsg (B_CANCEL);
cmsg.AddPointer ("source", panel);
panel->Messenger().SendMessage (&cmsg);
return B_SKIP_MESSAGE;
}
示例7: FileTypesWindow
void
FileTypes::MessageReceived(BMessage *message)
{
switch (message->what) {
case kMsgSettingsChanged:
fSettings.UpdateFrom(message);
break;
case kMsgOpenTypesWindow:
if (fTypesWindow == NULL) {
fTypesWindow = new FileTypesWindow(fSettings.Message());
fTypesWindow->Show();
fWindowCount++;
} else
fTypesWindow->Activate(true);
break;
case kMsgTypesWindowClosed:
fTypesWindow = NULL;
_WindowClosed();
break;
case kMsgOpenApplicationTypesWindow:
if (fApplicationTypesWindow == NULL) {
fApplicationTypesWindow = new ApplicationTypesWindow(
fSettings.Message());
fApplicationTypesWindow->Show();
fWindowCount++;
} else
fApplicationTypesWindow->Activate(true);
break;
case kMsgApplicationTypesWindowClosed:
fApplicationTypesWindow = NULL;
_WindowClosed();
break;
case kMsgTypeWindowClosed:
fTypeWindowCount--;
// supposed to fall through
case kMsgWindowClosed:
_WindowClosed();
break;
case kMsgOpenFilePanel:
{
// the open file panel sends us a message when it's done
const char* subTitle;
if (message->FindString("title", &subTitle) != B_OK)
subTitle = B_TRANSLATE("Open file");
int32 what;
if (message->FindInt32("message", &what) != B_OK)
what = B_REFS_RECEIVED;
BMessenger target;
if (message->FindMessenger("target", &target) != B_OK)
target = be_app_messenger;
BString title = B_TRANSLATE("FileTypes");
if (subTitle != NULL && subTitle[0]) {
title.Append(": ");
title.Append(subTitle);
}
fFilePanel->SetMessage(new BMessage(what));
fFilePanel->Window()->SetTitle(title.String());
fFilePanel->SetTarget(target);
if (!fFilePanel->IsShowing())
fFilePanel->Show();
break;
}
case B_SILENT_RELAUNCH:
// In case we were launched via the add-on, there is no types
// window yet.
if (fTypesWindow == NULL)
PostMessage(kMsgOpenTypesWindow);
break;
case B_CANCEL:
if (fWindowCount == 0)
PostMessage(B_QUIT_REQUESTED);
break;
case B_SIMPLE_DATA:
RefsReceived(message);
break;
default:
BApplication::MessageReceived(message);
break;
}
}
示例8: fileNameNoExt
//.........这里部分代码省略.........
*/
}
}
// comment start
header.ReplaceAll("%COMMS%", commentBlockStart.String());
// comment cont'd
header.ReplaceAll("%COMMC%", commentBlockCont.String());
// comment cont'd lazy (blank if possible)
header.ReplaceAll("%COMML%", commentBlockLazy.String());
// comment end
header.ReplaceAll("%COMME%", commentBlockEnd.String());
// comment line end
commentBlockLineEnd << "\n";
header.ReplaceAll("\n", commentBlockLineEnd.String());
err = B_OK;
break;
}
case 'optf':
{
const char *args[] = {path.Path(), NULL};
err = be_roster->Launch(sTrackerSig, 1, (char **)args);
//printf("err %s\n", strerror(err));
err = B_CANCELED;
break;
}
case 'seta':
{
MimeRefFilter filter("application/x-person");
BPath path;
entry_ref people;
if (find_directory(B_USER_DIRECTORY, &path) == B_OK)
{
path.Append("people");
get_ref_for_path(path.Path(), &people);
}
BFilePanel *panel;
panel = new BFilePanel(B_OPEN_PANEL, NULL, &people,
B_FILE_NODE, false, NULL, &filter);
// trick to synchronously use BFilePanel
PanelHandler *handler = new PanelHandler;
if (panel->Window()->Lock())
{
panel->Window()->AddHandler(handler);
panel->Window()->Unlock();
}
panel->SetTarget(BMessenger(handler));
panel->Show();
if (handler->Wait() < B_OK)
break;
if (!handler->Message())
break;
if (handler->Message()->what == B_CANCEL)
break;
entry_ref ref;
//panel->Message()->PrintToStream();
if (panel->GetNextSelectedRef(&ref) == B_OK)
{
//printf("ref:%s\n", ref.name);
path.SetTo(&ref);
dir.WriteAttr("pe:author_people", B_STRING_TYPE, 0LL,
path.Path(), strlen(path.Path()));
}
delete panel;
delete handler;
err = B_CANCELED;
break;
}
case B_ABOUT_REQUESTED:
{
BString tmpPath("/tmp/Pe-HeaderHeader-About-");
tmpPath << system_time() << "-" << getpid() << ".txt";
entry_ref ref;
get_ref_for_path(tmpPath.String(), &ref);
{
BFile f(&ref, B_CREATE_FILE | B_WRITE_ONLY);
err = f.InitCheck();
if (err < 0)
break;
f.Write(sAboutText, strlen(sAboutText));
f.SetPermissions(0444);
}
BMessage msg(B_REFS_RECEIVED);
msg.AddRef("refs", &ref);
err = be_app_messenger.SendMessage(&msg);
err = B_CANCELED;
break;
}
case 0:
err = B_CANCELED;
break;
default:
break;
}
delete menu;
return err;
}
示例9: msg
void
ServerWindow::DCCGetDialog (
BString nick,
BString file,
BString size,
BString ip,
BString port)
{
BMessage msg (DCC_ACCEPT), reply;
msg.AddString ("bowser:nick", nick.String());
msg.AddString ("bowser:file", file.String());
msg.AddString ("bowser:size", size.String());
msg.AddString ("bowser:ip", ip.String());
msg.AddString ("bowser:port", port.String());
//bool handled (false);
// ignore this part until some minor details with DCC Prefs are worked out
/*
const char *directory = "/boot/home/";
entry_ref ref;
BEntry entry;
create_directory (directory, 0777);
if (entry.SetTo (directory) == B_NO_ERROR
if (entry.GetRef (&ref) == B_NO_ERROR)
{
BDirectory dir (&ref);
BEntry file_entry;
struct stat s;
if (file_entry.SetTo (&dir, file.String()) == B_NO_ERROR
&& file_entry.GetStat (&s) == B_NO_ERROR
&& S_ISREG (s.st_mode))
{
BString buffer;
BAlert *alert;
int32 which;
buffer << "The file \""
<< file
<< "\" already exists in the specified folder. "
"Do you want to continue the transfer?";
alert = new BAlert (
"DCC Request",
buffer.String(),
"Refuse",
"Get",
"Resume",
B_WIDTH_AS_USUAL,
B_OFFSET_SPACING,
B_WARNING_ALERT);
which = alert->Go();
if (which == 0)
{
return;
}
if (which == 2)
{
BFile file (&file_entry, B_READ_ONLY);
off_t position;
BPath path;
file.GetSize (&position);
file_entry.GetPath (&path);
msg.AddString ("path", path.Path());
msg.AddInt64 ("pos", position);
AddResumeData (&msg);
return;
}
}
msg.AddRef ("directory", &ref);
msg.AddString ("name", file);
sMsgr.SendMessage (&msg);
handled = true;
}
}
*/
BFilePanel *panel;
BString text;
text << nick
<< ": "
<< file
<< " ("
<< size
<< " bytes)";
panel = new BFilePanel (
B_SAVE_PANEL,
&sMsgr,
0,
//.........这里部分代码省略.........
示例10: MessageReceived
void CharismaWindow::MessageReceived(BMessage *message)
{
char buf[B_PATH_NAME_LENGTH+1024];
BWindow *w;
entry_ref ref;
BEntry entry;
BPath path;
switch (message->what){
case kMsg_About:
about();
break;
case kMsg_SelectDirectory:
w=selectdirpanel->Window();
w->Lock();
sprintf(buf,"Current: %s",g_webdir);
currentdir->SetText(buf);
w->Unlock();
selectdirpanel->Show();
break;
case kMsg_DirSelected:
if(message->FindRef("refs", 0, &ref)) break;
entry.SetTo(&ref);
entry.GetPath(&path);
sprintf(g_webdir,"%s/",path.Path());
sprintf(buf,
"The new Web directory is: %s\n"
"If you wish to use previously acquired data, you should move or copy them here.\n"
"This modification will take effect for Stamina when Stamina is re-launched.",
g_webdir);
message->FindRef("refs",&ref);
(new BAlert("Charisma message",buf,"OK"))->Go();
saveprefs();
break;
case kMsg_ExternalControl:
extcontrol_item->SetMarked(!extcontrol_item->IsMarked());
update_proxy_settings();
break;
case kMsg_NetposAutosettings:
netposautoset_item->SetMarked(!netposautoset_item->IsMarked());
setnetpos();
break;
case kMsg_ClearHits:
hitcount=0;
break;
case kMsg_ProxySettings:
update_proxy_settings();
setnetpos();
break;
default:
BWindow::MessageReceived(message);
break;
}
}
示例11: MessageReceived
void PrefsWindow::MessageReceived(BMessage *msg)
{
switch (msg->what) {
case MSG_OK: { // "Start" button clicked
read_volumes_prefs();
read_memory_prefs();
read_graphics_prefs();
SavePrefs();
send_quit_on_close = false;
PostMessage(B_QUIT_REQUESTED);
be_app->PostMessage(ok_message);
break;
}
case MSG_CANCEL: // "Quit" button clicked
send_quit_on_close = false;
PostMessage(B_QUIT_REQUESTED);
be_app->PostMessage(B_QUIT_REQUESTED);
break;
case B_ABOUT_REQUESTED: { // "About" menu item selected
ShowAboutWindow();
break;
}
case MSG_ZAP_PRAM: // "Zap PRAM File" menu item selected
ZapPRAM();
break;
case MSG_VOLUME_INVOKED: { // Double-clicked on volume name, toggle read-only flag
int selected = volume_list->CurrentSelection();
if (selected >= 0) {
const char *str = PrefsFindString("disk", selected);
BStringItem *item = (BStringItem *)volume_list->RemoveItem(selected);
delete item;
char newstr[256];
if (str[0] == '*')
strcpy(newstr, str+1);
else {
strcpy(newstr, "*");
strcat(newstr, str);
}
PrefsReplaceString("disk", newstr, selected);
volume_list->AddItem(new BStringItem(newstr), selected);
volume_list->Select(selected);
}
break;
}
case MSG_ADD_VOLUME:
add_volume_panel->Show();
break;
case MSG_CREATE_VOLUME:
create_volume_panel->Show();
break;
case MSG_ADD_VOLUME_PANEL: {
entry_ref ref;
if (msg->FindRef("refs", &ref) == B_NO_ERROR) {
BEntry entry(&ref, true);
BPath path;
entry.GetPath(&path);
if (entry.IsFile()) {
PrefsAddString("disk", path.Path());
volume_list->AddItem(new BStringItem(path.Path()));
} else if (entry.IsDirectory()) {
BVolume volume;
if (path.Path()[0] == '/' && strchr(path.Path()+1, '/') == NULL && entry.GetVolume(&volume) == B_NO_ERROR) {
int32 i = 0;
dev_t d;
fs_info info;
while ((d = next_dev(&i)) >= 0) {
fs_stat_dev(d, &info);
if (volume.Device() == info.dev) {
PrefsAddString("disk", info.device_name);
volume_list->AddItem(new BStringItem(info.device_name));
}
}
}
}
}
break;
}
case MSG_CREATE_VOLUME_PANEL: {
entry_ref dir;
if (msg->FindRef("directory", &dir) == B_NO_ERROR) {
BEntry entry(&dir, true);
BPath path;
entry.GetPath(&path);
path.Append(msg->FindString("name"));
create_volume_panel->Window()->Lock();
BView *background = create_volume_panel->Window()->ChildAt(0);
NumberControl *v = (NumberControl *)background->FindView("hardfile_size");
int size = v->Value();
char cmd[1024];
sprintf(cmd, "dd if=/dev/zero \"of=%s\" bs=1024k count=%d", path.Path(), size);
//.........这里部分代码省略.........
示例12: msg
void
ServerAgent::DCCGetDialog (
BString nick,
BString file,
BString size,
BString ip,
BString port)
{
BMessage msg (M_DCC_ACCEPT), reply;
msg.AddString ("vision:nick", nick.String());
msg.AddString ("vision:file", file.String());
msg.AddString ("vision:size", size.String());
msg.AddString ("vision:ip", ip.String());
msg.AddString ("vision:port", port.String());
BFilePanel *panel;
BString text;
text << nick
<< ": "
<< file
<< " ("
<< size
<< " bytes)";
panel = new BFilePanel (
B_SAVE_PANEL,
&fSMsgr,
0,
0,
false,
&msg);
panel->SetButtonLabel (B_DEFAULT_BUTTON, "Accept");
panel->SetButtonLabel (B_CANCEL_BUTTON, "Refuse");
panel->SetSaveText (file.String());
BWindow *panelWindow (panel->Window());
if (panelWindow->Lock())
{
panelWindow->SetTitle (text.String());
panelWindow->SetFlags (panelWindow->Flags() | B_AVOID_FOCUS);
panelWindow->AddFilter (new DCCFileFilter (panel, msg));
if (vision_app->GetBool ("dccAutoAccept"))
{
BDirectory path (vision_app->GetString ("dccDefPath"));
if (path.InitCheck() == B_OK)
panel->SetPanelDirectory(&path);
}
if (vision_app->GetBool ("dccAutoAccept"))
{
panelWindow->Hide();
BButton *button (dynamic_cast<BButton *>(panel->Window()->FindView ("default button")));
if (button)
button->Invoke();
}
panelWindow->Unlock();
panel->Show();
// hack trick to ensure that the file panel doesn't take over the keyboard focus
// when it pops up
panelWindow->Lock();
panelWindow->SetFlags (panelWindow->Flags() & ~B_AVOID_FOCUS);
panelWindow->Unlock();
}
}
示例13: YabFilePanelLooper
BEntry *YabFilePanel::MyFilePanel(const char *name, const char *directory, const char* filename, int mode)
{
BEntry *myEntry = NULL;
entry_ref ref;
sem_id semaphore = create_sem(0, "yabfilepanel");
YabFilePanelLooper *myLooper = new YabFilePanelLooper(semaphore);
myLooper->Run();
if(directory)
{
myEntry=new BEntry(directory);
if(myEntry->GetRef(&ref)!=B_OK)
{
myEntry->Unset();
myEntry->SetTo("/boot/home/");
myEntry->GetRef(&ref);
}
myEntry->Unset();
delete myEntry;
}
BFilePanel *myFilePanel = NULL;
switch(mode)
{
case 0:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
break;
case 1:
myFilePanel = new BFilePanel(B_SAVE_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE, false, NULL, NULL, true, true);
if (filename) myFilePanel->SetSaveText(filename);
break;
case 2:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_DIRECTORY_NODE, false, NULL, NULL, true, true);
break;
case 3:
myFilePanel = new BFilePanel(B_OPEN_PANEL, new BMessenger(myLooper, myLooper), &ref, B_FILE_NODE|B_DIRECTORY_NODE, false, NULL, NULL, true, true);
break;
}
if(name) myFilePanel->Window()->SetTitle(name);
myFilePanel->Show();
bool inloop = true;
while(inloop)
{
while(acquire_sem_etc(semaphore, 1, B_RELATIVE_TIMEOUT, 10000)==B_TIMED_OUT) ;
myEntry = myLooper->GetChosenFile();
inloop = false;
/*
if(mode!=2)
inloop = false;
else
{
if(myEntry->IsDirectory())
inloop = false;
else
{
myFilePanel->Show();
}
}
*/
}
myLooper->Lock();
myLooper->Quit();
delete_sem(semaphore);
delete myFilePanel;
return myEntry;
}
示例14: FileTypesWindow
void
FileTypes::MessageReceived(BMessage* message)
{
switch (message->what) {
case kMsgSettingsChanged:
fSettings.UpdateFrom(message);
break;
case kMsgOpenTypesWindow:
if (fTypesWindow == NULL) {
fTypesWindow = new FileTypesWindow(fSettings.Message());
if (fArgvType.Length() > 0) {
// Set the window to the type that was requested on the
// command line (-type), we do this only once, if we
// ever opened more than one FileTypesWindow.
fTypesWindow->SelectType(fArgvType.String());
fArgvType = "";
}
fTypesWindow->Show();
fWindowCount++;
} else
fTypesWindow->Activate(true);
break;
case kMsgTypesWindowClosed:
fTypesWindow = NULL;
_WindowClosed();
break;
case kMsgOpenApplicationTypesWindow:
if (fApplicationTypesWindow == NULL) {
fApplicationTypesWindow = new ApplicationTypesWindow(
fSettings.Message());
fApplicationTypesWindow->Show();
fWindowCount++;
} else
fApplicationTypesWindow->Activate(true);
break;
case kMsgApplicationTypesWindowClosed:
fApplicationTypesWindow = NULL;
_WindowClosed();
break;
case kMsgTypeWindowClosed:
fTypeWindowCount--;
// supposed to fall through
case kMsgWindowClosed:
_WindowClosed();
break;
case kMsgOpenFilePanel:
{
// the open file panel sends us a message when it's done
const char* subTitle;
if (message->FindString("title", &subTitle) != B_OK)
subTitle = B_TRANSLATE("Open file");
int32 what;
if (message->FindInt32("message", &what) != B_OK)
what = B_REFS_RECEIVED;
BMessenger target;
if (message->FindMessenger("target", &target) != B_OK)
target = be_app_messenger;
BString title = B_TRANSLATE("FileTypes");
if (subTitle != NULL && subTitle[0]) {
title.Append(": ");
title.Append(subTitle);
}
uint32 flavors = B_FILE_NODE;
if (message->FindBool("allowDirs"))
flavors |= B_DIRECTORY_NODE;
fFilePanel->SetNodeFlavors(flavors);
fFilePanel->SetMessage(new BMessage(what));
fFilePanel->Window()->SetTitle(title.String());
fFilePanel->SetTarget(target);
if (!fFilePanel->IsShowing())
fFilePanel->Show();
break;
}
case B_SILENT_RELAUNCH:
// In case we were launched via the add-on, there is no types
// window yet.
if (fTypesWindow == NULL)
PostMessage(kMsgOpenTypesWindow);
break;
case B_CANCEL:
if (fWindowCount == 0)
PostMessage(B_QUIT_REQUESTED);
break;
case B_SIMPLE_DATA:
//.........这里部分代码省略.........
示例15: firstWord
bool
ClientWindow::ParseCmd (const char *data)
{
BString firstWord (GetWord(data, 1).ToUpper());
if (firstWord == "/WALLOPS" // we need to insert a ':' before parm2
|| firstWord == "/SQUIT" // for the user
|| firstWord == "/PRIVMSG")
{
BString theCmd (firstWord.RemoveAll ("/")),
theRest (RestOfString (data, 2));
BMessage send (M_SERVER_SEND);
AddSend (&send, theCmd);
if (theRest != "-9z99")
{
AddSend (&send, " :");
AddSend (&send, theRest);
}
AddSend (&send, endl);
return true;
}
if (firstWord == "/KILL") // we need to insert a ':' before parm3
{ // for the user
BString theCmd (firstWord.RemoveAll ("/")),
theTarget (GetWord (data, 2)),
theRest (RestOfString (data, 3));
BMessage send (M_SERVER_SEND);
AddSend (&send, theCmd);
AddSend (&send, " ");
AddSend (&send, theTarget);
if (theRest != "-9z99")
{
AddSend (&send, " :");
AddSend (&send, theRest);
}
AddSend (&send, endl);
return true;
}
// some quick aliases for scripts, these will of course be
// moved to an aliases section eventually
if (firstWord == "/SOUNDPLAY"
|| firstWord == "/CL-AMP")
{
app_info ai;
be_app->GetAppInfo (&ai);
BEntry entry (&ai.ref);
BPath path;
entry.GetPath (&path);
path.GetParent (&path);
//path.Append ("data");
path.Append ("scripts");
if (firstWord == "/SOUNDPLAY")
path.Append ("soundplay-hey");
else
path.Append ("cl-amp-clr");
BMessage *msg (new BMessage);
msg->AddString ("exec", path.Path());
msg->AddPointer ("client", this);
thread_id execThread = spawn_thread (
ExecPipe,
"exec_thread",
B_LOW_PRIORITY,
msg);
resume_thread (execThread);
return true;
}
if (firstWord == "/ABOUT")
{
be_app_messenger.SendMessage (B_ABOUT_REQUESTED);
return true;
}
if (firstWord == "/AWAY")
{
BString theReason (RestOfString (data, 2));
BString tempString;
if (theReason != "-9z99")
//.........这里部分代码省略.........