From: Steve Brokenshire Date: Sat, 9 Jul 2016 10:01:49 +0000 (+0100) Subject: Merge branch 'master' of ssh://gelforn.xestia.co.uk/scmrepos/xestiaab X-Git-Tag: release-0.14~2^2~2 X-Git-Url: http://Server1/repobrowser/?p=xestiaab%2F.git;a=commitdiff_plain;h=77c692f2d711f7140eab5bc12ae445d307b961cc;hp=e6968c57878efdbc17f99b090a427308b67eeb24 Merge branch 'master' of ssh://gelforn.xestia.co.uk/scmrepos/xestiaab --- diff --git a/source/bitmaps/icons/accunsupported.png b/source/bitmaps/icons/accunsupported.png new file mode 100644 index 0000000..705c425 Binary files /dev/null and b/source/bitmaps/icons/accunsupported.png differ diff --git a/source/common/preferences.cpp b/source/common/preferences.cpp index d8c1a53..009afea 100644 --- a/source/common/preferences.cpp +++ b/source/common/preferences.cpp @@ -195,6 +195,41 @@ XABPreferences::XABPreferences(wxString PreferencesFilename){ AccSSL, AccUsr, AccPass, AccPrefix, AccDir, AccRef); + } else { + + cfgfile->Read(wxT("accountdir"), &AccDir); + accountaddressvalid = cfgfile->Read(wxT("address"), &AccAdr); + accountportvalid = cfgfile->Read(wxT("port"), &AccPort); + accountsslvalid = cfgfile->Read(wxT("ssl"), &AccSSLInc); + if (AccSSLInc == wxT("true")){ + AccSSL = TRUE; + } + else { + AccSSL = FALSE; + } + accountusernamevalid = cfgfile->Read(wxT("username"), &AccUsr); + accountpasswordvalid = cfgfile->Read(wxT("password"), &AccPass); + accountdirprefixvalid = cfgfile->Read(wxT("prefix"), &AccPrefix); + accountrefreshvalid = cfgfile->Read(wxT("refresh"), &AccRef); + + if (AccDir.Len() > 4){ + + accountdirvalid = TRUE; + + } + + // Make sure it is not bigger than 65535 or less than 1. + // If so, default to port 8008. + + if (accountport < 1 || accountport > 65535){ + accountport = 8008; + accountportvalid = TRUE; + } + + accounts.AddAccount(accountname, EntryValue, AccAdr, AccPort, + AccSSL, AccUsr, AccPass, + AccPrefix, AccDir, AccRef); + } // Clear up for the next account. diff --git a/source/common/timers.cpp b/source/common/timers.cpp index e95347e..88bbb3e 100644 --- a/source/common/timers.cpp +++ b/source/common/timers.cpp @@ -423,13 +423,13 @@ void wxETagProcessTimer::ReloadAccounts(){ AccountDir = PrefData.accounts.GetAccountDirectory(i); AccountType = PrefData.accounts.GetAccountType(i); - + if (AccountDir.IsEmpty()){ continue; } - if (AccountType == wxT("Local") || AccountType == wxT("local")){ - continue; + if (AccountType != wxT("CardDAV") && AccountType != wxT("carddav")){ + continue; } AccountDir.Trim(); diff --git a/source/contacteditor/frmContactEditor-Save.cpp b/source/contacteditor/frmContactEditor-Save.cpp index bf743ee..ffaa5a0 100644 --- a/source/contacteditor/frmContactEditor-Save.cpp +++ b/source/contacteditor/frmContactEditor-Save.cpp @@ -29,6 +29,15 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) { + // Do not save if the account is an unsupported account. + + if (boolUnsupportedAccount == true){ + + wxMessageBox(_("Cannot make changes to a contact from an unsupported account type."), _("Unsupported account"), wxICON_ERROR); + return; + + } + // Check if Display As combo box has a value in it. // Do not go any further if there is no value. @@ -2462,7 +2471,7 @@ void frmContactEditor::SaveContact( wxCommandEvent& event ) wxStringTokenizer wSTFilename(wxSContactFilename, wxT("/")); #endif - + XABPreferences PrefData(PrefDir); wxString AccountType; diff --git a/source/contacteditor/frmContactEditor.cpp b/source/contacteditor/frmContactEditor.cpp index 4acb350..b5ef96e 100644 --- a/source/contacteditor/frmContactEditor.cpp +++ b/source/contacteditor/frmContactEditor.cpp @@ -159,6 +159,12 @@ void frmContactEditor::SetupContact( wxString AccountName ) } +void frmContactEditor::SetupAccountData(bool UnsupportedAccount){ + + boolUnsupportedAccount = UnsupportedAccount; + +} + int frmContactEditor::GetLastInt(std::map *MapData){ /* diff --git a/source/contacteditor/frmContactEditor.h b/source/contacteditor/frmContactEditor.h index 1cd897e..fabe5cb 100644 --- a/source/contacteditor/frmContactEditor.h +++ b/source/contacteditor/frmContactEditor.h @@ -313,6 +313,7 @@ class frmContactEditor : public frmContactEditorADT frmContactEditor( wxWindow* parent ); void SetupHeaders(); void SetupContact(wxString AccountName); + void SetupAccountData(bool UnsupportedAccount); void SetupPointers(frmActivityMgr *ActMgr, wxETagProcessTimer *ETagProc, frmMain *MainPtrInc); bool LoadContact(wxString Filename); @@ -711,6 +712,8 @@ class frmContactEditor : public frmContactEditorADT wxString wxSContactFilename; wxString wxSContactAccount; bool boolContactModified; + bool boolUnsupportedAccount = false; + int intSeekSelectedData; /* Section for saving/loading data */ diff --git a/source/frmMain.cpp b/source/frmMain.cpp index ac703d8..99784a6 100644 --- a/source/frmMain.cpp +++ b/source/frmMain.cpp @@ -138,6 +138,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 +154,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)); @@ -560,6 +567,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 +601,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 +646,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 +1112,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 +1173,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 +1218,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 +1268,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 +1278,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 +1483,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 +1508,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 +1532,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 +1553,7 @@ void frmMain::LoadPreferences(){ wxString vCardFilename; wxString vCardDataString; wxString vCardFilenameFull; - + bool ProcFiles = vcardaccdir.GetFirst(&vCardFilename, wxEmptyString, wxDIR_FILES); while(ProcFiles){ @@ -1946,7 +1982,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 +1996,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); @@ -2810,6 +2857,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 +3127,7 @@ void frmMain::ShowContactMenu( wxMouseEvent& event ){ bool EnableRefresh = FALSE; - if (!ActiveAccount.IsEmpty()){ + if (!ActiveAccount.IsEmpty() && (ActiveAccountType == "CardDAV" || ActiveAccountType == "carddav")){ EnableRefresh = TRUE; diff --git a/source/frmMain.h b/source/frmMain.h index 8a5ac21..8d3c58d 100644 --- a/source/frmMain.h +++ b/source/frmMain.h @@ -171,6 +171,7 @@ class frmMain : public frmMainADT int AccountID; int AccountNetID; int AccountGrpID; + int AccountUnsupportedID; int AccountNoneID; bool ReloadAccounts = FALSE; bool AscendingMode = FALSE; diff --git a/source/frmPreferences.cpp b/source/frmPreferences.cpp index b12e712..c9623e0 100644 --- a/source/frmPreferences.cpp +++ b/source/frmPreferences.cpp @@ -43,6 +43,7 @@ frmPreferencesADT( parent ) wxMemoryInputStream astream(icons_accinet_png, sizeof(icons_accinet_png)); wxMemoryInputStream bstream(icons_acclocal_png, sizeof(icons_acclocal_png)); + wxMemoryInputStream cstream(icons_accunsupported_png, sizeof(icons_accunsupported_png)); wxImage icons_accinet_png(astream, wxBITMAP_TYPE_PNG); wxBitmap AccInet(icons_accinet_png, -1); @@ -53,9 +54,15 @@ frmPreferencesADT( parent ) wxBitmap AccNIcon(icons_acclocal_png, -1); wxIcon wxIAccNIcon; wxIAccNIcon.CopyFromBitmap(AccNIcon); + + wxImage icons_accunsupported_png(cstream, wxBITMAP_TYPE_PNG); + wxBitmap AccUIcon(icons_accunsupported_png, -1); + wxIcon wxIAccUIcon; + wxIAccUIcon.CopyFromBitmap(AccUIcon); AccountID = AccImgList->Add(wxIAccNIcon); AccountNetID = AccImgList->Add(wxIAccInet); + AccountUnsupportedID = AccImgList->Add(wxIAccUIcon); NbtPreferences->RemovePage(1); @@ -125,14 +132,27 @@ void frmPreferences::ModifyABAccount( wxCommandEvent& event ) long lstAccountsIndex = -1; wxString AccFilename = GetAccountsFile(); wxString AccName; + wxString AccType; wxFileConfig *cfgfile = new wxFileConfig("", "", AccFilename); - + // Get the account name. lstAccountsIndex = lstAccounts->GetNextItem(lstAccountsIndex, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); + + // Check that the account type is a supported account type. + + AccType = preferences->accounts.GetAccountType((int)lstAccountsIndex); + + if (AccType != "CardDAV" && AccType != "carddav" && + AccType != "Local" && AccType != "local"){ + + wxMessageBox(_("Cannot modify the selected account settings as the account type is unsupported."), _("Unsupported account type"), wxICON_ERROR); + return; + + } AccName = preferences->accounts.GetAccountName((int)lstAccountsIndex); @@ -226,6 +246,10 @@ void frmPreferences::DeleteABAccount( wxCommandEvent& event ) AccountDirFull.Append(wxT("carddav")); + } else { + + AccountDirFull.Append(AccountType.Lower()); + } lstAccounts->DeleteItem(lstAccountsIndex); @@ -254,6 +278,9 @@ void frmPreferences::DeleteABAccount( wxCommandEvent& event ) } + btnAccountModify->Enable(FALSE); + btnAccountDelete->Enable(FALSE); + } void frmPreferences::LoadPreferences( wxInitDialogEvent& event ) @@ -344,6 +371,10 @@ void frmPreferences::ReloadAccounts(){ col0.SetImage(AccountID); + } else { + + col0.SetImage(AccountUnsupportedID); + } long itemindex = lstAccounts->InsertItem( col0 );