- Timestamp:
- 07/09/07 22:13:35 (2 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
Mulberry/branches/v4.1d1/MacOS/Sources/Application/General/CMulberryApp.cp
r74 r97 34 34 #include "CAdbkManagerWindow.h" 35 35 #include "CAdbkSearchWindow.h" 36 #include "CAddressBookDoc.h"37 36 #include "CAddressBookWindow.h" 38 37 #include "CAdminLock.h" … … 52 51 #include "CICSupport.h" 53 52 #include "CLetterWindow.h" 54 #include "CLocalAddressBook.h"55 53 #include "CMacroEditDialog.h" 56 54 #include "CMailAccountManager.h" … … 423 421 else if (CAdminLock::sAdminLock.mNoQuit) 424 422 { 425 // Look for option key426 KeyMap km;427 ::GetKeys(km); // Get keyboard state428 423 // Check for option key 429 bool optionKey = (( ((unsigned char*) km)[0x3A>>3] >> (0x3A & 7) ) & 1); 430 bool shiftKey = (( ((unsigned char*) km)[0x38>>3] >> (0x38 & 7) ) & 1); 431 bool cmdKey = (( ((unsigned char*) km)[0x37>>3] >> (0x37 & 7) ) & 1); 424 UInt32 modifiers = ::GetCurrentKeyModifiers(); 425 bool option_key = modifiers & optionKey; 426 bool shift_key = modifiers & shiftKey; 427 bool cmd_key = modifiers & cmdKey; 432 428 433 429 // See if allowed to quit by existing docs 434 if ((!option Key || !shiftKey || !cmdKey) && AttemptQuit(inSaveOption))430 if ((!option_key || !shift_key || !cmd_key) && AttemptQuit(inSaveOption)) 435 431 { 436 432 // First close it … … 607 603 608 604 // Look for option key 609 KeyMap km; 610 ::GetKeys(km); // Get keyboard state 611 bool cmdKey = (( ((unsigned char*) km)[0x37>>3] >> (0x37 & 7) ) & 1); 605 bool cmd_key = ::GetCurrentKeyModifiers() & cmdKey; 612 606 613 607 // Possible disconnect prompt 614 608 if (!prefs.mDisconnected.GetValue() && prefs.mPromptDisconnected.GetValue() && CTCPSocket::WillDial() || 615 cmd Key)609 cmd_key) 616 610 { 617 611 CErrorDialog::EDialogResult result = CErrorDialog::PoseDialog(CErrorDialog::eErrDialog_Caution, … … 792 786 793 787 // Force manager to update all accounts 794 CAddressBookManager::sAddressBookManager->StartLocal(); 795 CAddressBookManager::sAddressBookManager->SyncAccounts(CPreferences::sPrefs->mAddressAccounts.GetValue()); 788 CAddressBookManager::sAddressBookManager->SyncAccounts(); 796 789 } 797 790 else 798 791 { 799 792 // Force manager to update all accounts 800 CAddressBookManager::sAddressBookManager->SyncAccounts( CPreferences::sPrefs->mAddressAccounts.GetValue());793 CAddressBookManager::sAddressBookManager->SyncAccounts(); 801 794 } 802 795 } … … 982 975 case cmd_Preferences: 983 976 { 984 // Look for option key985 KeyMap km;986 ::GetKeys(km); // Get keyboard state987 977 // Check for option key 988 bool option Key = (( ((unsigned char*) km)[0x3A>>3] >> (0x3A & 7) ) & 1);978 bool option_key = ::GetCurrentKeyModifiers() & optionKey; 989 979 990 980 // If option key and logging allowed then do log prefs 991 if (option Key && CAdminLock::sAdminLock.mAllowLogging)981 if (option_key && CAdminLock::sAdminLock.mAllowLogging) 992 982 { 993 983 CLog::DoLoggingOptions(); … … 1034 1024 1035 1025 case cmd_NewAddressBook: 1036 // Do local new if only local address books 1037 if (CAddressBookManager::sAddressBookManager->GetProtocolList().empty()) 1038 MakeNewAddressBookDoc(); 1039 else if (CPreferences::sPrefs->mUse3Pane.GetValue()) 1026 if (CPreferences::sPrefs->mUse3Pane.GetValue()) 1040 1027 { 1041 1028 // Show three pane window and force to contacts tab … … 1046 1033 } 1047 1034 } 1048 else if (CPreferences::sPrefs->mUse3Pane.GetValue())1035 else 1049 1036 { 1050 1037 // Show address book manager … … 1054 1041 1055 1042 case cmd_OpenAddressBook: 1056 // Do local open if only local address books 1057 if (CAddressBookManager::sAddressBookManager->GetProtocolList().empty()) 1058 ChooseAddressBookDoc(); 1059 else if (CPreferences::sPrefs->mUse3Pane.GetValue()) 1043 if (CPreferences::sPrefs->mUse3Pane.GetValue()) 1060 1044 { 1061 1045 // Show three pane window and force to contacts tab … … 1066 1050 } 1067 1051 } 1068 else if (CPreferences::sPrefs->mUse3Pane.GetValue())1052 else 1069 1053 { 1070 1054 // Show address book manager … … 1823 1807 // Sync address books 1824 1808 if (!stopped_adbk && CAddressBookManager::sAddressBookManager) 1825 CAddressBookManager::sAddressBookManager->SyncAccounts( CPreferences::sPrefs->mAddressAccounts.GetValue());1809 CAddressBookManager::sAddressBookManager->SyncAccounts(); 1826 1810 1827 1811 // Sync calendars … … 2190 2174 break; 2191 2175 2192 case kAddressBookDocType:2193 // Make sure prefs exists - force if not2194 if (!mPrefsLoaded) StartUp();2195 2196 if (CAdminLock::sAdminLock.mNoLocalAdbks)2197 {2198 ::SysBeep(1);2199 break;2200 }2201 2202 // Only open if not quitting2203 if (mState != programState_Quitting)2204 {2205 // Check for existing file2206 CAddressBook* adbk = (CAddressBook*) CAddressBookManager::sAddressBookManager->CheckLocalOpen(inMacFSSpec);2207 2208 // Does window already exist?2209 if (adbk)2210 {2211 CAddressBookWindow* theWindow = CAddressBookWindow::FindWindow(adbk);2212 2213 if (theWindow)2214 // Found existing window so select2215 FRAMEWORK_WINDOW_TO_TOP(theWindow)2216 2217 adbk = NULL;2218 }2219 else2220 {2221 try2222 {2223 // Create address book2224 adbk = new CLocalAddressBook(inMacFSSpec);2225 2226 // Open it2227 adbk->Open();2228 }2229 catch (...)2230 {2231 CLOG_LOGCATCH(...);2232 2233 // Remove from manager2234 if (adbk)2235 adbk->Close();2236 delete adbk;2237 }2238 }2239 }2240 break;2241 2176 } 2242 2177 … … 2267 2202 2268 2203 } // CMulberryApp::ChooseLetterDoc 2269 2270 // Create address book doc2271 void CMulberryApp::MakeNewAddressBookDoc()2272 {2273 CLocalAddressBook* adbk = NULL;2274 try2275 {2276 // Create address book2277 adbk = new CLocalAddressBook(NULL);2278 2279 // New it2280 adbk->New();2281 }2282 catch (...)2283 {2284 CLOG_LOGCATCH(...);2285 2286 // Remove from manager2287 if (adbk)2288 adbk->Close();2289 delete adbk;2290 }2291 }2292 2293 // Choose an address book document2294 void CMulberryApp::ChooseAddressBookDoc()2295 {2296 // Send AE for recording2297 PPx::FSObject fspec;2298 if (PP_StandardDialogs::AskOpenOneFile(kAddressBookDocType, fspec, kNavDefaultNavDlogOptions | kNavAllowPreviews | kNavAllFilesInPopup))2299 OpenDocument(&fspec);2300 2301 } // CMulberryApp::ChooseAddressBookDoc2302 2204 2303 2205 // Respond to an AppleEvent