bool CaMuleExternalConnector::OnInit() { #ifndef __WINDOWS__ #if wxUSE_ON_FATAL_EXCEPTION // catch fatal exceptions wxHandleFatalExceptions(true); #endif #endif // If we didn't know that OnInit is called only once when creating the // object, it could cause a memory leak. The two pointers below should // be free()'d before assigning the new value. // cppcheck-suppress publicAllocationError m_strFullVersion = strdup((const char *)unicode2char(GetMuleVersion())); m_strOSDescription = strdup((const char *)unicode2char(wxGetOsDescription())); // Handle uncaught exceptions InstallMuleExceptionHandler(); bool retval = wxApp::OnInit(); OnInitCommandSet(); InitCustomLanguages(); SetLocale(m_language); return retval; }
bool CamulecmdApp::OnCmdLineParsed(wxCmdLineParser& parser) { m_HasCmdOnCmdLine = parser.Found(wxT("command"), &m_CmdString); if (m_CmdString.Lower().StartsWith(wxT("help"))) { OnInitCommandSet(); printf("%s %s\n", m_appname, (const char *)unicode2char(GetMuleVersion())); Parse_Command(m_CmdString); exit(0); } m_interactive = !m_HasCmdOnCmdLine; return CaMuleExternalConnector::OnCmdLineParsed(parser); }
CamuleDlg::CamuleDlg( wxWindow* pParent, const wxString &title, wxPoint where, wxSize dlg_size) : wxFrame( pParent, -1, title, where, dlg_size, wxCAPTION|wxRESIZE_BORDER|wxSYSTEM_MENU|wxDIALOG_NO_PARENT| wxRESIZE_BORDER|wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxCLOSE_BOX, wxT("aMule")), m_activewnd(NULL), m_transferwnd(NULL), m_serverwnd(NULL), m_sharedfileswnd(NULL), m_searchwnd(NULL), m_chatwnd(NULL), m_statisticswnd(NULL), m_kademliawnd(NULL), m_prefsDialog(NULL), m_srv_split_pos(0), m_imagelist(16,16), m_tblist(32,32), m_prefsVisible(false), m_wndToolbar(NULL), m_wndTaskbarNotifier(NULL), m_nActiveDialog(DT_NETWORKS_WND), m_is_safe_state(false), m_BlinkMessages(false), m_CurrentBlinkBitmap(24), m_last_iconizing(0), m_skinFileName(), m_clientSkinNames(CLIENT_SKIN_SIZE) { // Initialize skin names m_clientSkinNames[Client_Green_Smiley] = wxT("Transfer"); m_clientSkinNames[Client_Red_Smiley] = wxT("Connecting"); m_clientSkinNames[Client_Yellow_Smiley] = wxT("OnQueue"); m_clientSkinNames[Client_Grey_Smiley] = wxT("A4AFNoNeededPartsQueueFull"); m_clientSkinNames[Client_White_Smiley] = wxT("StatusUnknown"); m_clientSkinNames[Client_ExtendedProtocol_Smiley] = wxT("ExtendedProtocol"); m_clientSkinNames[Client_SecIdent_Smiley] = wxT("SecIdent"); m_clientSkinNames[Client_BadGuy_Smiley] = wxT("BadGuy"); m_clientSkinNames[Client_CreditsGrey_Smiley] = wxT("CreditsGrey"); m_clientSkinNames[Client_CreditsYellow_Smiley] = wxT("CreditsYellow"); m_clientSkinNames[Client_Upload_Smiley] = wxT("Upload"); m_clientSkinNames[Client_Friend_Smiley] = wxT("Friend"); m_clientSkinNames[Client_eMule_Smiley] = wxT("eMule"); m_clientSkinNames[Client_mlDonkey_Smiley] = wxT("mlDonkey"); m_clientSkinNames[Client_eDonkeyHybrid_Smiley] = wxT("eDonkeyHybrid"); m_clientSkinNames[Client_aMule_Smiley] = wxT("aMule"); m_clientSkinNames[Client_lphant_Smiley] = wxT("lphant"); m_clientSkinNames[Client_Shareaza_Smiley] = wxT("Shareaza"); m_clientSkinNames[Client_xMule_Smiley] = wxT("xMule"); m_clientSkinNames[Client_Unknown] = wxT("Unknown"); m_clientSkinNames[Client_InvalidRating_Smiley] = wxT("InvalidRatingOnFile"); m_clientSkinNames[Client_PoorRating_Smiley] = wxT("PoorRatingOnFile"); m_clientSkinNames[Client_GoodRating_Smiley] = wxT("GoodRatingOnFile"); m_clientSkinNames[Client_FairRating_Smiley] = wxT("FairRatingOnFile"); m_clientSkinNames[Client_ExcellentRating_Smiley] = wxT("ExcellentRatingOnFile"); m_clientSkinNames[Client_CommentOnly_Smiley] = wxT("CommentOnly"); m_clientSkinNames[Client_Encryption_Smiley] = wxT("Encrypted"); // wxWidgets send idle events to ALL WINDOWS by default... *SIGH* wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); wxUpdateUIEvent::SetMode(wxUPDATE_UI_PROCESS_SPECIFIED); wxInitAllImageHandlers(); Apply_Clients_Skin(); #ifdef __WINDOWS__ wxSystemOptions::SetOption(wxT("msw.remap"), 0); #endif #if !(wxCHECK_VERSION(2, 9, 0) && defined(__WXMAC__)) // this crashes on Mac with wx 2.9 SetIcon(wxICON(aMule)); #endif srand(time(NULL)); // Create new sizer and stuff a wxPanel in there. wxFlexGridSizer *s_main = new wxFlexGridSizer(1); s_main->AddGrowableCol(0); s_main->AddGrowableRow(0); wxPanel* p_cnt = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize); s_main->Add(p_cnt, 0, wxGROW|wxEXPAND, 0); muleDlg(p_cnt, false, true); SetSizer(s_main, true); m_serverwnd = new CServerWnd(p_cnt, m_srv_split_pos); AddLogLineN(wxEmptyString); AddLogLineN(wxT(" - ") + CFormat(_("This is aMule %s based on eMule.")) % GetMuleVersion()); AddLogLineN(wxT(" ") + CFormat(_("Running on %s")) % wxGetOsDescription()); AddLogLineN(wxT(" - ") + wxString(_("Visit http://www.amule.org to check if a new version is available."))); AddLogLineN(wxEmptyString); #ifdef ENABLE_IP2COUNTRY m_GeoIPavailable = true; m_IP2Country = new CIP2Country(thePrefs::GetConfigDir()); #else m_GeoIPavailable = false; #endif m_searchwnd = new CSearchDlg(p_cnt); m_transferwnd = new CTransferWnd(p_cnt); m_sharedfileswnd = new CSharedFilesWnd(p_cnt); m_statisticswnd = new CStatisticsDlg(p_cnt, theApp->m_statistics); m_chatwnd = new CChatWnd(p_cnt); m_kademliawnd = CastChild(wxT("kadWnd"), CKadDlg); m_serverwnd->Show(false); m_searchwnd->Show(false); m_transferwnd->Show(false); m_sharedfileswnd->Show(false); m_statisticswnd->Show(false); m_chatwnd->Show(false); // Create the GUI timer gui_timer=new wxTimer(this,ID_GUI_TIMER_EVENT); if (!gui_timer) { AddLogLineN(_("FATAL ERROR: Failed to create Timer")); exit(1); } // Set transfers as active window Create_Toolbar(thePrefs::VerticalToolbar()); SetActiveDialog(DT_TRANSFER_WND, m_transferwnd); m_wndToolbar->ToggleTool(ID_BUTTONDOWNLOADS, true ); bool override_where = (where != wxDefaultPosition); bool override_size = ( (dlg_size.x != DEFAULT_SIZE_X) || (dlg_size.y != DEFAULT_SIZE_Y) ); if (!LoadGUIPrefs(override_where, override_size)) { // Prefs not loaded for some reason, exit AddLogLineC(wxT("Error! Unable to load Preferences") ); return; } // Prepare the dialog, sets the splitter-position (AFTER window size is set) m_transferwnd->Prepare(); m_is_safe_state = true; // Init statistics stuff, better do it asap m_statisticswnd->Init(); m_kademliawnd->Init(); m_searchwnd->UpdateCatChoice(); if (thePrefs::UseTrayIcon()) { CreateSystray(); } Show(true); // Must we start minimized? if (thePrefs::GetStartMinimized()) { DoIconize(true); } // Set shortcut keys wxAcceleratorEntry entries[] = { wxAcceleratorEntry(wxACCEL_CTRL, wxT('Q'), wxID_EXIT) }; SetAcceleratorTable(wxAcceleratorTable(itemsof(entries), entries)); ShowED2KLinksHandler( thePrefs::GetFED2KLH() ); wxNotebook* logs_notebook = CastChild( ID_SRVLOG_NOTEBOOK, wxNotebook); wxNotebook* networks_notebook = CastChild( ID_NETNOTEBOOK, wxNotebook); wxASSERT(logs_notebook->GetPageCount() == 4); wxASSERT(networks_notebook->GetPageCount() == 2); for (uint32 i = 0; i < logs_notebook->GetPageCount(); ++i) { m_logpages[i].page = logs_notebook->GetPage(i); m_logpages[i].name = logs_notebook->GetPageText(i); } for (uint32 i = 0; i < networks_notebook->GetPageCount(); ++i) { m_networkpages[i].page = networks_notebook->GetPage(i); m_networkpages[i].name = networks_notebook->GetPageText(i); } DoNetworkRearrange(); }
bool CaMuleExternalConnector::OnCmdLineParsed(wxCmdLineParser& parser) { if (parser.Found(wxT("version"))) { printf("%s %s\n", m_appname, (const char *)unicode2char(GetMuleVersion())); return false; } if (!parser.Found(wxT("config-file"), &m_configFileName)) { m_configFileName = GetConfigDir() + wxT("remote.conf"); } wxString aMuleConfigFile; if (parser.Found(wxT("create-config-from"), &aMuleConfigFile)) { aMuleConfigFile = FinalizeFilename(aMuleConfigFile); if (!::wxFileExists(aMuleConfigFile)) { fprintf(stderr, "%s\n", (const char *)unicode2char(wxT("FATAL ERROR: File does not exist: ") + aMuleConfigFile)); exit(1); } CECFileConfig aMuleConfig(aMuleConfigFile); LoadAmuleConfig(aMuleConfig); SaveConfigFile(); m_configFile->Flush(); exit(0); } LoadConfigFile(); if ( !parser.Found(wxT("host"), &m_host) ) { if ( m_host.IsEmpty() ) { m_host = wxT("localhost"); } } long port; if (parser.Found(wxT("port"), &port)) { m_port = port; } wxString pass_plain; if (parser.Found(wxT("password"), &pass_plain)) { if (!pass_plain.IsEmpty()) { m_password.Decode(MD5Sum(pass_plain).GetHash()); } else { m_password.Clear(); } } if (parser.Found(wxT("write-config"))) { m_NeedsConfigSave = true; } parser.Found(wxT("locale"), &m_language); if (parser.Found(wxT("help"))) { parser.Usage(); return false; } m_KeepQuiet = parser.Found(wxT("quiet")); m_Verbose = parser.Found(wxT("verbose")); return true; }