void Address::ExecuteBrowser(const String& cUrl) { int nError=0; if (fork() == 0) { set_thread_priority( -1, 0 ); nError = execlp("/Applications/Webster/Webster","/Applications/Webster/Webster",cUrl.c_str(),NULL); } if (nError == -1) { if (errno == ENOENT) { Alert* pcAlert = new Alert("Address...","Could not find Webster browser.",m_pcIcon->LockBitmap(),0,"_OK",NULL); m_pcIcon->UnlockBitmap(); pcAlert->CenterInScreen(); pcAlert->Go(new Invoker()); } else { Alert* pcAlert = new Alert("Address...","Error launching Webster browser.",m_pcIcon->LockBitmap(),0,"_OK",NULL); m_pcIcon->UnlockBitmap(); pcAlert->CenterInScreen(); pcAlert->Go(new Invoker()); } } }
void LoginView::PopulateIcons() { try { FILE* fp = fopen("/etc/passwd","r"); struct passwd* psPwd; int nIcon = 0; while((psPwd = fgetpwent( fp )) != NULL ) { // Let's remove users that don't need to be there and then add them to the iconview // System users (eg "www", "mail") have uids between 1 and 99. Filter them out. if( psPwd->pw_uid >= 100 || psPwd->pw_uid == 0 ) { pcUserIconView->AddIcon(GetImageFromIcon(psPwd->pw_name),new IconData()); pcUserIconView->AddIconString(nIcon,psPwd->pw_name); nIcon++; } } pcUserIconView->Layout(); } catch (...) { Alert* pcError = new Alert("Unable to load users","I am unable to load users, please contact the Syllable development group.",0x00,"Oh no!!!",NULL); pcError->Go(new Invoker()); } }
void TailWin::Save(const char *cFileName) // From AEdit { static std::string cBuffer; TextView::buffer_type vLines; int iLineNo, iLineTotal=0; vLines=m_TextView->GetBuffer(); iLineTotal=vLines.size(); ofstream foutfile(cFileName); if(foutfile){ for(iLineNo=0;iLineNo<iLineTotal;iLineNo++){ cBuffer=m_TextView->GetBuffer()[iLineNo]; foutfile << cBuffer << endl; } } else{ //Open an error window Alert* sFileAlert = new Alert(STR_ERROR_SAVEFILE_TITLE, STR_ERROR_SAVEFILE_TEXT, 0x00, STR_ERROR_SAVEFILE_OKBUTTON.c_str(), NULL); sFileAlert->Go(); } foutfile.close(); }
void IFaceWin::ApplyChanges( void ) { IFaceType_t nType = m_pcDdmType->GetCurrentString() == MSG_IFWIN_TYPE_STATIC ? Static : DHCP; bool bDefault = m_pcIFace->IsDefault(); bool bError = false; switch ( nType ) { case Static: { IPAddress_t nIP, nNM, nGW; String cError; if( !ParseIPAddress( m_pcTxtAddress->GetValue().AsString( ), &nIP ) ) { bError = true; cError = MSG_IFWIN_ERR_IP_ADDRESS; } else if( !ParseIPAddress( m_pcTxtNetmask->GetValue().AsString( ), &nNM ) ) { bError = true; cError = MSG_IFWIN_ERR_NETMASK; } else if( !ParseIPAddress( m_pcTxtGateway->GetValue().AsString( ), &nGW ) ) { bError = true; cError = MSG_IFWIN_ERR_GATEWAY; } if( bError ) { Alert *pcAlert = new Alert( MSG_IFWIN_ERR_TITLE, cError, Alert::ALERT_WARNING, 0, MSG_IFWIN_ERR_CLOSE.c_str(), NULL ); pcAlert->Go( new Invoker( new Message() ) ); } else { m_pcIFace->SetAddress( nIP ); m_pcIFace->SetNetmask( nNM ); m_pcIFace->SetGateway( nGW ); } break; } case DHCP: break; } if( !bError ) { m_pcIFace->SetType( nType ); m_pcIFace->SetEnabled( m_pcCbEnabled->GetValue().AsBool( ) ); m_pcIFace->SetDefault( bDefault ); Messenger cMsnger( m_pcParent ); cMsnger.SendMessage( new Message( ApplyInterfaceChanges ) ); } }
void Address::DisplayAbout() { String cTitle = (String)"About " + (String)PLUGIN_NAME + (String)"..."; String cInfo = (String)"Version: " + (String)PLUGIN_VERSION + (String)"\n\nAuthor: " + (String)PLUGIN_AUTHOR + (String)"\n\nDesc: " + (String)PLUGIN_DESC; Alert* pcAlert = new Alert(cTitle.c_str(),cInfo.c_str(),m_pcIcon->LockBitmap(),0,"_OK",NULL); m_pcIcon->UnlockBitmap(); pcAlert->Go(new Invoker()); pcAlert->MakeFocus(); }
void MainView::ShowAbout(void) { Alert* sAbout = new Alert("sIRC 0.03", "sIRC 0.01\n\n" "Syllable Internet Relay Chat Client\n" "By James Coxon 2006\n" "*****@*****.**" , 0x00, "Close", NULL); sAbout->Go(new Invoker); }
void DockCamera::HandleMessage(Message* pcMessage) { switch (pcMessage->GetCode()) { case M_CAMERA_ABOUT: { String cTitle = (String)"About " + (String)PLUGIN_NAME + (String)"..."; String cInfo = (String)"Version: " + (String)PLUGIN_VERSION + (String)"\n\nAuthor: " + (String)PLUGIN_AUTHOR + (String)"\n\nDesc: " + (String)PLUGIN_DESC; Alert* pcAlert = new Alert(cTitle.c_str(),cInfo.c_str(),m_pcIcon->LockBitmap(),0,"OK",NULL); pcAlert->Go(new Invoker()); pcAlert->MakeFocus(); break; } case M_PREFS: { ShowPrefs(m_pcPlugin->GetPath()); break; } case M_PREFS_SEND_TO_PARENT: { pcMessage->FindFloat("click",&vClick); pcMessage->FindFloat("key/instant",&vInstant); pcMessage->FindFloat("key/delay",&vDelay); pcMessage->FindFloat("delay",&vDelayTime); SaveSettings(); LoadSettings(); pcPrefsWin->Close(); pcPrefsWin = NULL; break; } case M_PRINT_SCREEN: { if (bFirst) { bFirst = false; } else { pcCameraDelayedLooper->AddTimer(pcCameraDelayedLooper,CAMERA_ID,0); } break; } } }
void TailWin::HandleMessage(Message *msg) { switch(msg->GetCode()) { case ID_COPY: m_TextView->SelectAll(); m_TextView->Copy(); m_TextView->ClearSelection(); break; case ID_CLEAR: m_TextView->Clear(); break; case ID_SAVE: { FileRequester *fr = new FileRequester(FileRequester::SAVE_REQ, new Messenger(this)); fr->Show(); fr->MakeFocus(); } break; case ID_OPEN: { FileRequester *fr = new FileRequester(FileRequester::LOAD_REQ,new Messenger(this)); fr->Show(); fr->MakeFocus(); } break; case M_SAVE_REQUESTED: { const char *path; if(msg->FindString("file/path", &path) == 0) { Save(path); } } break; case M_LOAD_REQUESTED: { os::String path; if (msg->FindString("file/path",&path) == 0 ) { RemoveTimer(this,10); m_TextView->Clear(); m_FileName = new String(path); AddTimer(this, 10, 1000000, false); } break; } case ID_ABOUT: { char* abouttext = new char[ STR_ABOUT.size() + 64 ]; sprintf( abouttext, STR_ABOUT.c_str(), ATAIL_VERSION ); Alert *About = new Alert(STR_ABOUT_WINTITLE, abouttext, 0x00, STR_ABOUT_OKBUTTON.c_str(), NULL); About->Go(new Invoker(new Message(ID_NOP), 0)); } break; case ID_QUIT: Application::GetInstance()->PostMessage(M_QUIT); break; case ID_NOP: // Do nothing, dummy ID for the about requester break; default: Window::HandleMessage(msg); } }
void BrowserWindow::HandleMessage( Message * pcMsg ) { BrowserWebView *pcWebView = GetCurrentWebView(); switch( pcMsg->GetCode() ) { case ID_URL_CHANGED: { bool bFinal = false; pcMsg->FindBool( "final", &bFinal ); if( bFinal ) { String cURL = ""; int nSelection = -1; if( pcMsg->FindInt32( "selection", &nSelection ) == EOK ) cURL = m_pcUrlEdit->GetItem( nSelection ); else { cURL = m_pcUrlEdit->GetCurrentString(); m_pcUrlEdit->AppendItem( cURL ); } OpenURL( cURL ); } break; } case ID_SET_STATUS_BAR_TEXT: { String cText; if( pcMsg->FindString( "text", &cText ) == EOK ) m_pcStatusBar->SetText( "text", cText ); break; } case ID_CLEAR_STATUS_BAR_TEXT: { m_pcStatusBar->SetText( "text", "" ); break; } case ID_CREATE_WINDOW: { BrowserWindow *pcWindow; String cURL; Rect cFrame; /* Use the supplied dimensions if they've been provided, otherwise clone the current Window */ if( pcMsg->FindRect( "frame", &cFrame ) != EOK ) cFrame = GetFrame(); pcWindow = new BrowserWindow( cFrame ); if( pcMsg->FindString( "url", &cURL ) == EOK ) pcWindow->OpenURL( cURL ); pcWindow->Show(); pcWindow->MakeFocus(); /* Tell BrowserApp about the new window */ Application::GetInstance()->PostMessage( ID_WINDOW_OPENED ); if( pcMsg->IsSourceWaiting() ) { WebCore::Page *pcPage; View *pcTab; /* The new window will only have one tab at this stage so it's safe to always get tab #0 */ pcTab = pcWindow->m_pcTabView->GetTabView( 0 ); pcPage = static_cast<BrowserWebView*>( pcTab )->GetWebCoreFrame()->page(); Message cReply( ID_CREATE_WINDOW_REPLY ); cReply.AddPointer( "page", pcPage ); pcMsg->SendReply( &cReply ); } break; } case ID_CREATE_TAB: { String cURL; if( pcMsg->FindString( "url", &cURL ) == EOK ) { uint nTabIndex; nTabIndex = CreateTab( cURL ); if( pcMsg->IsSourceWaiting() ) { WebCore::Page *pcPage; View *pcTab; pcTab = m_pcTabView->GetTabView( nTabIndex ); pcPage = static_cast<BrowserWebView*>( pcTab )->GetWebCoreFrame()->page(); Message cReply( ID_CREATE_WINDOW_REPLY ); cReply.AddPointer( "page", pcPage ); pcMsg->SendReply( &cReply ); } } break; } case ID_BUTTON_BACK: { pcWebView->GoBack(); UpdateButtonState( false ); break; } case ID_BUTTON_FORWARD: { pcWebView->GoForward(); UpdateButtonState( false ); break; } case ID_BUTTON_RELOAD: { pcWebView->Reload(); break; } case ID_BUTTON_STOP: { pcWebView->Stop(); UpdateButtonState( false ); break; } case ID_BUTTON_HOME: { OpenURL( m_pcSettings->GetString( "homepage", "about:blank" ) ); break; } case ID_MENU_APP_ABOUT: { Alert* pcAbout = new Alert( "About Webster", "Webster " WEBSTER_VERSION " (Alpha)\nA WebCore based web browser\n\n© Copyright Kristian Van Der Vliet, 2008\nArno Klenke, 2004-2007\nKurt Skauen, 2001\n" "\nWebster is released under the Gnu Public License (GPL)\n", Alert::ALERT_INFO, 0x00, "Ok", NULL ); pcAbout->Go( NULL ); break; } case ID_MENU_WIN_NEW_TAB: { CreateTab( "" ); break; } case ID_MENU_WIN_CLOSE_TAB: { DestroyTab( m_pcTabView->GetSelection() ); break; } case ID_MENU_EDIT_CUT: { pcWebView->Cut(); break; } case ID_MENU_EDIT_COPY: { pcWebView->Copy(); break; } case ID_MENU_EDIT_PASTE: { pcWebView->Paste(); break; } case ID_MENU_EDIT_DELETE: { pcWebView->Delete(); break; } case ID_MENU_SETTINGS_CONFIGURE: { Rect cSettingsFrame = m_pcGuiSettings->GetRect( "settings", m_cSettingsFrame ); SettingsWindow *pcSettingsWindow = new SettingsWindow( cSettingsFrame, "Webster settings", this, m_pcWebSettings, m_pcSettings, m_pcGuiSettings ); pcSettingsWindow->Show(); pcSettingsWindow->MakeFocus(); break; } case ID_SETTINGS_SAVE: { Settings *pcSettings; if( pcMsg->FindPointer( "settings", (void**)&pcSettings ) == EOK ) { delete m_pcSettings; m_pcSettings = pcSettings; m_pcSettings->Save(); } WebSettings *pcWebSettings; if( pcMsg->FindPointer( "web_settings", (void**)&pcWebSettings ) == EOK ) { delete m_pcWebSettings; m_pcWebSettings = pcWebSettings; } break; } case ID_SETTINGS_APPLY: { Settings *pcSettings; if( pcMsg->FindPointer( "settings", (void**)&pcSettings ) == EOK ) { delete m_pcSettings; m_pcSettings = pcSettings; } WebSettings *pcWebSettings; if( pcMsg->FindPointer( "web_settings", (void**)&pcWebSettings ) == EOK ) { delete m_pcWebSettings; m_pcWebSettings = pcWebSettings; } break; } case ID_MENU_BOOKMARKS_ADD: { String cShortTitle, cLongTitle, cURL; pcWebView->GetTitle( cShortTitle, cLongTitle ); cURL = pcWebView->GetCurrentURL(); m_pcBookmarksManager->AddBookmark( cLongTitle, cURL ); break; } case ID_MENU_BOOKMARKS_MANAGE: { String cPath; if( pcMsg->FindString( "path", &cPath ) != EOK ) break; /* XXXKV: This is a really rubbish way to manage bookmarks: we should have a proper in-application dialog to do it */ /* Open a filebrowser window */ if( fork() == 0 ) { set_thread_priority( -1, 0 ); execlp( "/system/bin/FileBrowser", "/system/bin/FileBrowser", cPath.c_str(), NULL ); } break; } case ID_BOOKMARK_GO: { String cURL; if( pcMsg->FindString( "url", &cURL ) == EOK ) OpenURL( cURL ); break; } case ID_TAB_CHANGED: { ChangeTab( m_pcTabView->GetSelection() ); break; } case ID_WEBVIEW_SET_TITLE: { String cShortTitle, cLongTitle; uint nTabIndex; if( pcMsg->FindString( "short", &cShortTitle ) == EOK && pcMsg->FindString( "long", &cLongTitle ) == EOK && pcMsg->FindInt32( "index", (int32*)&nTabIndex ) == EOK ) { m_pcTabView->SetTabTitle( nTabIndex, cShortTitle ); /* If this is the currently selected tab, set the Window title to the full page title */ if( nTabIndex == m_pcTabView->GetSelection() ) SetTitle( cLongTitle ); } break; } case ID_WEBVIEW_LOAD_STARTED: { String cURL; uint nTabIndex; if( pcMsg->FindString( "url", &cURL ) == EOK && pcMsg->FindInt32( "index", (int32*)&nTabIndex ) == EOK ) { if( nTabIndex == m_pcTabView->GetSelection() ) { m_pcUrlEdit->SetCurrentString( cURL.c_str() ); UpdateButtonState( true ); } } break; } case ID_WEBVIEW_LOAD_FINISHED: { uint nTabIndex; if( pcMsg->FindInt32( "index", (int32*)&nTabIndex ) == EOK ) if( nTabIndex == m_pcTabView->GetSelection() ) UpdateButtonState( false ); break; } default: { fprintf( stderr, "Unknown message with code #%d\n", pcMsg->GetCode() ); Window::HandleMessage( pcMsg ); break; } } }
AlertApp::AlertApp(int argc, char* argv[]) : Application( "application/x-vnd.rgc-alert") { if(argc <= 1) // no arguments { printf("Usage: alert title text alert_icon(Alert::ALERT_INFO is default) button1 [button2] [button3]\n"); exit (EXIT_FAILURE); } String title = "Untitled Alert"; String text = "Alert text goes here."; String bitmap = "Alert icon here(Alert::ALERT_INFO is default)"; String button1 = "Ok"; String button2 = "Ok"; String button3 = "Ok"; int buttons = 1; for(int32 i = 1; i < argc; i++) { switch (i) { case 1: title = argv[i]; break; case 2: text = argv[i]; break; case 3: bitmap = argv[i]; break; case 4: button1 = argv[i]; break; case 5: button2 = argv[i]; buttons = 2; break; case 6: button3 = argv[i]; buttons = 3; break; } } Alert * alert; switch (buttons) { case 1: { if (strcmp(bitmap.c_str(),"Alert::ALERT_INFO")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_INFO, 0x00, button1.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_WARNING")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_WARNING, 0x00, button1.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_QUESTION")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_QUESTION, 0x00, button1.c_str(), NULL); break; } else { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_INFO, 0x00, button1.c_str(), NULL); break; } break; } case 2: { if (strcmp(bitmap.c_str(),"Alert::ALERT_INFO")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_INFO, 0x00, button1.c_str(),button2.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_WARNING")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_WARNING, 0x00, button1.c_str(),button2.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_QUESTION")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_QUESTION, 0x00, button1.c_str(),button2.c_str(), NULL); break; } else { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_INFO, 0x00, button1.c_str(),button2.c_str(), NULL); break; } break; } case 3: { if (strcmp(bitmap.c_str(),"Alert::ALERT_INFO")==0) { alert = new Alert(title.c_str(), text.c_str(),os::Alert::ALERT_INFO, 0x00, button1.c_str(),button2.c_str(),button3.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_WARNING")==0) { alert = new Alert(title.c_str(), text.c_str(),os::Alert::ALERT_WARNING, 0x00, button1.c_str(),button2.c_str(),button3.c_str(), NULL); break; } if (strcmp(bitmap.c_str(),"Alert::ALERT_QUESTION")==0) { alert = new Alert(title.c_str(), text.c_str(),Alert::ALERT_QUESTION, 0x00, button1.c_str(),button2.c_str(),button3.c_str(), NULL); break; } else { alert = new Alert(title.c_str(), text.c_str(),os::Alert::ALERT_INFO, 0x00, button1.c_str(),button2.c_str(),button3.c_str(), NULL); break; } break; } default: exit (EXIT_FAILURE); break; } int reply = -1; reply = alert->Go(); switch (reply) { case 0: printf("%s\n", button1.c_str()); break; case 1: printf("%s\n", button2.c_str()); break; case 2: printf("%s\n", button3.c_str()); break; default: exit (EXIT_FAILURE); break; } PostMessage(M_QUIT); }