X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=blobdiff_plain;f=source%2FfrmMain.cpp;h=4dc43f6d90f1837155cf24e5886edaece88f4da9;hp=ac703d82b6c39b93013e181aa4063184e3d58ab2;hb=25716f74ecdac6cd5879b659ebc8aaa668261880;hpb=e6968c57878efdbc17f99b090a427308b67eeb24 diff --git a/source/frmMain.cpp b/source/frmMain.cpp index ac703d8..4dc43f6 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -54,7 +54,6 @@ #include "common/events.h" #include "common/dirs.h" #include "vcard/vcard.h" -#include "carddav/carddav.h" #include "contacteditor/frmContactEditor.h" #include "import/import.h" #include "export/export.h" @@ -85,6 +84,7 @@ DEFINE_EVENT_TYPE(WINDOW_EDIT); DEFINE_EVENT_TYPE(WINDOW_CLOSE); DEFINE_EVENT_TYPE(CONNSTAT_UPDATE); DEFINE_EVENT_TYPE(INVALIDSSLCERT); +DEFINE_EVENT_TYPE(INVALIDSSLCERTSTRING); DEFINE_EVENT_TYPE(GETSELECTEDLIST); DEFINE_EVENT_TYPE(SYNCACCOUNT); DEFINE_EVENT_TYPE(IMPORT_RESULTSSHOW); @@ -117,6 +117,7 @@ EVT_COMMAND(wxID_ANY, WINDOW_EDIT, frmMain::WindowEdit) EVT_COMMAND(wxID_ANY, WINDOW_CLOSE, frmMain::WindowDelete) EVT_COMMAND(wxID_ANY, CONNSTAT_UPDATE, frmMain::UpdateConnectionStatus) EVT_COMMAND(wxID_ANY, INVALIDSSLCERT, frmMain::InvalidSSLCertificate) +EVT_COMMAND(wxID_ANY, INVALIDSSLCERTSTRING, frmMain::InvalidSSLCertificateString) EVT_COMMAND(wxID_ANY, GETSELECTEDLIST, frmMain::GetSelectedList) EVT_COMMAND(wxID_ANY, SYNCACCOUNT, frmMain::SyncAccount) EVT_COMMAND(wxID_ANY, IMPORT_RESULTSSHOW, frmMain::ShowImportResults) @@ -138,6 +139,7 @@ frmMainADT( parent ) wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png)); wxMemoryInputStream cstream(icons_accgroup_png, sizeof(icons_accgroup_png)); wxMemoryInputStream dstream(icons_accnone_png, sizeof(icons_accnone_png)); + wxMemoryInputStream estream(icons_accunsupported_png, sizeof(icons_accunsupported_png)); wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG); wxBitmap AccInet(icons_accinet_png, -1); @@ -153,16 +155,22 @@ frmMainADT( parent ) wxBitmap AccGrp(icons_accgroup_png, -1); wxIcon wxIAccGrp; wxIAccGrp.CopyFromBitmap(AccGrp); - + wxImage icons_accnone_png(dstream, wxBITMAP_TYPE_PNG); wxBitmap AccNone(icons_accnone_png, -1); wxIcon wxIAccNone; wxIAccNone.CopyFromBitmap(AccNone); + + wxImage icons_accunsupported_png(estream, wxBITMAP_TYPE_PNG); + wxBitmap AccUnsupported(icons_accunsupported_png, -1); + wxIcon wxIAccUnsupported; + wxIAccUnsupported.CopyFromBitmap(AccUnsupported); AccountID = AccImgList->Add(wxIAccNIcon); AccountNetID = AccImgList->Add(wxIAccInet); AccountGrpID = AccImgList->Add(wxIAccGrp); AccountNoneID = AccImgList->Add(wxIAccNone); + AccountUnsupportedID = AccImgList->Add(wxIAccUnsupported); bmpIcon->SetIcon(AccImgList->GetIcon(AccountNoneID)); @@ -182,7 +190,40 @@ frmMainADT( parent ) wxImage icons_nossl_png(nosslstream, wxBITMAP_TYPE_PNG); imgNoSSL = new wxBitmap(icons_nossl_png, -1); - + + // Toolbar icons. + + wxMemoryInputStream addaddressbook(toolbar_addaddressbook_png, sizeof(toolbar_addaddressbook_png)); + wxMemoryInputStream preferences(toolbar_preferences_png, sizeof(toolbar_preferences_png)); + wxMemoryInputStream searchcontacts(toolbar_searchcontacts_png, sizeof(toolbar_searchcontacts_png)); + wxMemoryInputStream addcontact(toolbar_addcontact_png, sizeof(toolbar_addcontact_png)); + wxMemoryInputStream editcontact(toolbar_editcontact_png, sizeof(toolbar_editcontact_png)); + wxMemoryInputStream deletecontact(toolbar_deletecontact_png, sizeof(toolbar_deletecontact_png)); + + wxImage toolbar_addaddressbook_png(addaddressbook, wxBITMAP_TYPE_PNG); + imgAddAddressBook = new wxBitmap (toolbar_addaddressbook_png, -1); + tblMain->SetToolNormalBitmap(tbtNewAccount->GetId(), *imgAddAddressBook); + + wxImage toolbar_preferences_png(preferences, wxBITMAP_TYPE_PNG); + imgPreferences = new wxBitmap (toolbar_preferences_png, -1); + tblMain->SetToolNormalBitmap(tbtPreferences->GetId(), *imgPreferences); + + wxImage toolbar_searchcontacts_png(searchcontacts, wxBITMAP_TYPE_PNG); + imgSearchContacts = new wxBitmap (toolbar_searchcontacts_png, -1); + tblMain->SetToolNormalBitmap(tbtSearch->GetId(), *imgSearchContacts); + + wxImage toolbar_addcontact_png(addcontact, wxBITMAP_TYPE_PNG); + imgAddContact = new wxBitmap (toolbar_addcontact_png, -1); + tblMain->SetToolNormalBitmap(tbtAddContact->GetId(), *imgAddContact); + + wxImage toolbar_editcontact_png(editcontact, wxBITMAP_TYPE_PNG); + imgEditContact = new wxBitmap (toolbar_editcontact_png, -1); + tblMain->SetToolNormalBitmap(tbtEditContact->GetId(), *imgEditContact); + + wxImage toolbar_deletecontact_png(deletecontact, wxBITMAP_TYPE_PNG); + imgDeleteContact = new wxBitmap (toolbar_deletecontact_png, -1); + tblMain->SetToolNormalBitmap(tbtDeleteContact->GetId(), *imgDeleteContact); + // Activity Icon. wxMemoryInputStream act1(icons_act1_png, sizeof(icons_act1_png)); @@ -245,7 +286,7 @@ frmMainADT( parent ) #elif defined(__WIN32__) - int stbBottomData [4] = { -1, 16, 16, 16 }; + int stbBottomData [4] = { -1, 8, 8, 8 }; #else @@ -264,10 +305,8 @@ frmMainADT( parent ) stbBottom->GetFieldRect(3, rectActivity); SSLToolTip = new wxToolTip(wxT("")); - -#if defined(__WIN32__) - - imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint(rectOnline.GetX(),rectOnline.GetY()), wxDefaultSize, 0 ); + + imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectOnline.GetX()),(rectOnline.GetY())), wxDefaultSize, 0 ); imgConnStatus->SetBitmap(*imgOnline); imgConnStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ToggleConnectionStatus ), NULL, this ); @@ -280,23 +319,6 @@ frmMainADT( parent ) imgActivityStatus->SetBitmap(*imgActIconSleep); imgActivityStatus->Connect( wxEVT_LEFT_DCLICK, wxCommandEventHandler( frmMain::ShowActivityWindow ), NULL, this ); -#else - - imgConnStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectOnline.GetX()), (rectOnline.GetY())), wxDefaultSize, 0); - imgConnStatus->SetBitmap(*imgOnline); - imgConnStatus->Connect(wxEVT_LEFT_DCLICK, wxCommandEventHandler(frmMain::ToggleConnectionStatus), NULL, this); - - imgSSLStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectSSL.GetX()), (rectSSL.GetY())), wxDefaultSize, 0); - imgSSLStatus->SetBitmap(*imgNoSSL); - imgSSLStatus->SetToolTip(SSLToolTip); - imgSSLStatus->Connect(wxEVT_LEFT_DCLICK, wxCommandEventHandler(frmMain::ShowSSLCertificates), NULL, this); - - imgActivityStatus = new wxStaticBitmap(stbBottom, wxID_ANY, wxNullBitmap, wxPoint((rectActivity.GetX()), (rectActivity.GetY())), wxDefaultSize, 0); - imgActivityStatus->SetBitmap(*imgActIconSleep); - imgActivityStatus->Connect(wxEVT_LEFT_DCLICK, wxCommandEventHandler(frmMain::ShowActivityWindow), NULL, this); - -#endif - // Setup the window menu. // By default should be: @@ -368,17 +390,11 @@ void frmMain::QuitApp() { // Function to run when quitting. - - //Go through the windows and close each one (be it search - //or contact editor). Abort if user wants to cancel. - - // Close the contact editor windows. - - // Close the contact windows. - - // Close the search windows. - + // Write out the ETag databases. + + ETagProcTimer.Stop(); + ETagProcTimer.Notify(); // Save Preferences: Save the window position if that option is enabled. @@ -560,6 +576,10 @@ void frmMain::LoadContactList( wxTreeEvent& event ) imgSSLStatus->SetBitmap(*imgOffline); SSLToolTip->SetTip(wxT("SSL status is not applicable for this account")); AccountTypeFinal.Append(wxT("local")); + } else { + imgSSLStatus->SetBitmap(*imgOffline); + SSLToolTip->SetTip(wxT("SSL status is not applicable for this account")); + AccountTypeFinal.Append(AccountType.Lower()); } AccountIndex = i; @@ -590,6 +610,8 @@ void frmMain::LoadContactList( wxTreeEvent& event ) } else if (AccountType == wxT("Local")){ SSLToolTip->SetTip(wxT("SSL status is not applicable for this account")); AccountTypeFinal.Append(wxT("local")); + } else { + AccountTypeFinal.Append(AccountType.Lower()); } AccountIndex = i; @@ -633,7 +655,7 @@ void frmMain::LoadContactList( wxTreeEvent& event ) long ContactSeekPoint = 0; wxDir vcardaccdir(AccountDirFinal); - + // Get the wxTreeItemId and image icon and compare it to the list. if (ActiveItemIcon == AccountGrpID){ @@ -1099,6 +1121,17 @@ void frmMain::ShowContactEditorNew( wxCommandEvent& event ) return; } + + // Check if the account type is a valid account type, otherwise + // display an error message. + + if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" && + ActiveAccountType != "Local" && ActiveAccountType != "local"){ + + wxMessageBox(_("Cannot add a new contact as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR); + return; + + } // Add Pointer to SetupPointers for the ETagDB. @@ -1149,7 +1182,7 @@ void frmMain::ShowContactEditorEdit( wxCommandEvent& event ) return; } - + wxMemoryInputStream istream(bigimgs_contactpersonicon48_png, sizeof(bigimgs_contactpersonicon48_png)); wxImage bigimgs_contactpersonicon48i(istream, wxBITMAP_TYPE_PNG); wxBitmap contacticonbmp(bigimgs_contactpersonicon48i, -1); @@ -1194,6 +1227,13 @@ void frmMain::ShowContactEditorEdit( wxCommandEvent& event ) ContactEditor->SetupPointers(frameActMgr, &ETagProcTimer, this); ContactEditor->SetupHeaders(); + + if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" && + ActiveAccountType != "Local" && ActiveAccountType != "local"){ + + ContactEditor->SetupAccountData(true); + + } // Check if pointer is NULL (not from the search forms) or not. @@ -1237,7 +1277,7 @@ void frmMain::RefreshAddressBook( wxCommandEvent& event ){ if (!ActiveAccount.IsEmpty()){ - if (ActiveAccountType != wxT("Local")){ + if (ActiveAccountType == wxT("CardDAV") || ActiveAccountType == wxT("carddav")){ // Account type is not local. @@ -1247,7 +1287,7 @@ void frmMain::RefreshAddressBook( wxCommandEvent& event ){ } else { - wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported for this type of account")); + wxMessageBox(_("The refresh address book command is not supported with this type of account."), wxT("Not supported"), wxICON_ERROR); } @@ -1452,7 +1492,7 @@ void frmMain::LoadPreferences(){ ETagProcTimer.ReloadAccounts(); for (int i = 0; i < preferences.accounts.GetCount(); i++){ - + if ((preferences.accounts.GetAccountType(i) == wxT("Local") || preferences.accounts.GetAccountType(i) == wxT("local")) && HideLocalABs == TRUE){ @@ -1477,7 +1517,7 @@ void frmMain::LoadPreferences(){ AccName = preferences.accounts.GetAccountName(i); AccName.Trim(); AccountAccDirList.insert(std::make_pair(i, AccDirFull)); - + if (preferences.accounts.GetAccountType(i) == wxT("CardDAV") || preferences.accounts.GetAccountType(i) == wxT("carddav")){ @@ -1501,10 +1541,15 @@ void frmMain::LoadPreferences(){ AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountNetID, -1); - } else { + } else if (preferences.accounts.GetAccountType(i) == wxT("Local") || + preferences.accounts.GetAccountType(i) == wxT("local")) { AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountID, -1); + } else { + + AccountTreeId = treAccounts->AppendItem(RootNode, preferences.accounts.GetAccountName(i), AccountUnsupportedID, -1); + } // Go through the account directory and find contact files with @@ -1517,7 +1562,7 @@ void frmMain::LoadPreferences(){ wxString vCardFilename; wxString vCardDataString; wxString vCardFilenameFull; - + bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES); while(ProcFiles){ @@ -1946,7 +1991,7 @@ void frmMain::RevealContact(wxCommandEvent& event){ void frmMain::DeleteContact(wxCommandEvent& event){ // Delete a contact from the main window. - + // Check if a contact is selected. long intSelected = -1; @@ -1960,6 +2005,17 @@ void frmMain::DeleteContact(wxCommandEvent& event){ if (intSelected == -1){ return; } + + // Check if the account type is a valid account type, otherwise + // display an error message. + + if (ActiveAccountType != "CardDAV" && ActiveAccountType != "carddav" && + ActiveAccountType != "Local" && ActiveAccountType != "local"){ + + wxMessageBox(_("Cannot delete contact as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR); + return; + + } frmActivityMgr *frameActMgr = static_cast(ActMgrPtr); @@ -2075,13 +2131,14 @@ void frmMain::DeleteContact(wxCommandEvent& event){ if (nextChild == selectedChild){ wxSDataURL = prefaccounts.GetAccountDirPrefix(i) + wxT("/") + wxSplitFilename; + break; } } // Add task to the activity monitor to delete the contact. - + frameActMgr->AddTask(2, wxSContactName, ActiveAccount, wxSDataURL, wxSplitFilename, ContactsFileIndex[intContactSeekNum], wxT("")); } @@ -2595,7 +2652,7 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){ // Setup and display the form. - if (SSLCertificateIter == AccountCertificateData.end() || SSLCertificateIter->second->pCertInfo == NULL){ + if (SSLCertificateIter->second->pCertInfo == NULL){ wxMessageBox("No certificate information is available due to invalid connection details, connection being in progress or invalid certificate data received."); @@ -2622,7 +2679,7 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){ #else - std::map::iterator SSLColIter; + std::map::iterator SSLColIter; for (int i = 0; i < prefaccounts.GetCount(); i++){ @@ -2649,11 +2706,11 @@ void frmMain::ShowSSLCertificates( wxCommandEvent &event ){ SSLColIter = AccountSSLData.find(i); - SSLCertCollection SSLCertInfo = SSLColIter->second; - + SSLCertCollectionString SSLCertInfo = SSLColIter->second; + frmSSLCertificate *frameSSLCert = new frmSSLCertificate ( this ); frameSSLCert->StartCertFrom(0); - frameSSLCert->SetupCerts(SSLCertInfo); + frameSSLCert->SetupCertsString(SSLCertInfo); frameSSLCert->ShowModal(); delete frameSSLCert; @@ -2722,6 +2779,31 @@ void frmMain::InvalidSSLCertificate( wxCommandEvent &event ){ } +void frmMain::InvalidSSLCertificateString( wxCommandEvent &event ){ + + // Display the form for showing an invalid SSL certificate. + + frmInvalidSSLCertificate *frameISC = new frmInvalidSSLCertificate ( this ); + SSLInvalidCertNotifObjString *SSLICNObj = (SSLInvalidCertNotifObjString*)event.GetClientData(); + SSLCertCollectionString SSLCCData = SSLICNObj->CertCollection; + wxString AccountName = SSLICNObj->AccountName; + frameISC->LoadData(SSLCCData, AccountName); + frameISC->ShowModal(); + + int FinalConflictResult = frameISC->GetResult(); + + wxCommandEvent event2(ACTMGR_RESUMEPROC); + event2.SetClientData(SSLICNObj->QRNotifData); + event2.SetInt(FinalConflictResult); + + delete frameISC; + frameISC = NULL; + + frmActivityMgr *frameActMgr = static_cast(ActMgrPtr); + wxPostEvent(frameActMgr, event2); + +} + void frmMain::PauseAllTimers(){ // Pause all the account timers. @@ -2774,7 +2856,7 @@ void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, PCCERT_CONTEX #else -void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollection SSLCertInc){ +void frmMain::UpdateSSLAccountStatus(int AccountID, int SSLStatus, SSLCertCollectionString SSLCertInc){ // Delete existing data. @@ -2810,6 +2892,17 @@ void frmMain::SetupSSLStatus( int AccountID ){ } + // Check the account type is a supported account type. + + if (AccType != "CardDAV" && AccType != "carddav" && + AccType != "Local" && AccType != "local"){ + + SSLToolTip->SetTip(wxT("SSL is not enabled for this account")); + imgSSLStatus->SetBitmap(*imgNoSSL); + return; + + } + // Check if the account has SSL enabled. bool SSLInUse = prefaccounts.GetAccountSSL(AccountID); @@ -3069,7 +3162,7 @@ void frmMain::ShowContactMenu( wxMouseEvent& event ){ bool EnableRefresh = FALSE; - if (!ActiveAccount.IsEmpty()){ + if (!ActiveAccount.IsEmpty() && (ActiveAccountType == "CardDAV" || ActiveAccountType == "carddav")){ EnableRefresh = TRUE;