├── plugin ├── Support │ └── bin │ │ └── ApexLoader.app │ │ └── Contents │ │ ├── PkgInfo │ │ ├── MacOS │ │ └── ApexLoader │ │ ├── Resources │ │ ├── Login.nib │ │ ├── minus-8.png │ │ ├── plus-8.png │ │ └── English.lproj │ │ │ ├── MainMenu.nib │ │ │ └── InfoPlist.strings │ │ └── Info.plist ├── Commands │ ├── new run tests.tmCommand │ ├── Deploy Apex Page.tmCommand │ ├── new compile trigger.tmCommand │ ├── new exec anon.tmCommand │ ├── c1.tmCommand │ └── c2.tmCommand ├── info.plist └── Syntaxes │ └── Apex.tmLanguage ├── .gitignore ├── apexLoader ├── common │ ├── minus-8.png │ ├── plus-8.png │ ├── Login.nib │ │ ├── keyedobjects.nib │ │ ├── info.nib │ │ └── classes.nib │ ├── credential.h │ ├── ZKLoginController.h │ ├── credential.m │ └── ZKLoginController.m ├── apexLoader │ ├── English.lproj │ │ ├── InfoPlist.strings │ │ └── MainMenu.nib │ │ │ └── keyedobjects.nib │ ├── ApexLoader_Prefix.pch │ ├── main.m │ ├── Info.plist │ ├── ApexLoader.h │ ├── Loader.h │ ├── Options.h │ ├── Options.m │ ├── ApexLoader.m │ └── Loader.m └── sforce │ ├── zkBaseClient.h │ ├── zkSaveResult.h │ ├── zkSoapException.h │ ├── ZKPartnerEnvelope.h │ ├── ZKCodeLocation.m │ ├── ZKCodeCoverageWarning.m │ ├── ZKRecordTypeInfo.m │ ├── ZKPicklistEntry.m │ ├── zkSforce.h │ ├── ZKCodeLocation.h │ ├── zkChildRelationship.m │ ├── ZKRunTestSuccess.m │ ├── ZKRunTestFailure.m │ ├── ZKCodeCoverageWarning.h │ ├── ZKRunTestFailure.h │ ├── zkApexClient.h │ ├── zkXmlDeserializer.h │ ├── ZKRunTestSuccess.h │ ├── zkSoapException.m │ ├── ZKPartnerEnvelope.m │ ├── zkExecuteAnonResult.m │ ├── zkChildRelationship.h │ ├── zkQueryResult.h │ ├── zkRunTestResult.h │ ├── zkUserInfo.h │ ├── ZKCompileResult.m │ ├── ZKPicklistEntry.h │ ├── zkExecuteAnonResult.h │ ├── zkSaveResult.m │ ├── ZKRecordTypeInfo.h │ ├── ZKCompileResult.h │ ├── zkEnvelope.h │ ├── zkRunTestResult.m │ ├── ZKCodeCoverageResult.h │ ├── ZKCodeCoverageResult.m │ ├── zkSObject.h │ ├── zkBaseClient.m │ ├── zkSforceClient.h │ ├── zkXmlDeserializer.m │ ├── zkDescribeSObject.h │ ├── zkQueryResult.m │ ├── zkUserInfo.m │ ├── zkApexClient.m │ ├── zkDescribeField.h │ ├── zkEnvelope.m │ ├── zkDescribeSObject.m │ ├── zkDescribeField.m │ ├── zkSObject.m │ └── zkSforceClient.m └── README.md /plugin/Support/bin/ApexLoader.app/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPL???? -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *.mode1v3 3 | *.pbxuser 4 | build/ 5 | project.xcworkspace/ 6 | xcuserdata/ 7 | Bundles/ -------------------------------------------------------------------------------- /apexLoader/common/minus-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/apexLoader/common/minus-8.png -------------------------------------------------------------------------------- /apexLoader/common/plus-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/apexLoader/common/plus-8.png -------------------------------------------------------------------------------- /apexLoader/common/Login.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/apexLoader/common/Login.nib/keyedobjects.nib -------------------------------------------------------------------------------- /apexLoader/apexLoader/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/apexLoader/apexLoader/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/MacOS/ApexLoader: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/MacOS/ApexLoader -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Resources/Login.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/Resources/Login.nib -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Resources/minus-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/Resources/minus-8.png -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Resources/plus-8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/Resources/plus-8.png -------------------------------------------------------------------------------- /apexLoader/apexLoader/English.lproj/MainMenu.nib/keyedobjects.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/apexLoader/apexLoader/English.lproj/MainMenu.nib/keyedobjects.nib -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Resources/English.lproj/MainMenu.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/Resources/English.lproj/MainMenu.nib -------------------------------------------------------------------------------- /apexLoader/apexLoader/ApexLoader_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'ApexLoader' target in the 'ApexLoader' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Resources/English.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/superfell/ApexMate/HEAD/plugin/Support/bin/ApexLoader.app/Contents/Resources/English.lproj/InfoPlist.strings -------------------------------------------------------------------------------- /apexLoader/apexLoader/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ApexLoader 4 | // 5 | // Created by Simon Fell on 10/30/07. 6 | // Copyright Simon Fell 2007. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) 12 | { 13 | return NSApplicationMain(argc, (const char **) argv); 14 | } 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ApexMate is a plugin for the awesome OSX text editor TextMate. Using the plug-in you can easily save apex code to your Salesforce.com account, run tests etc. 2 | 3 | You can download a prebuilt version of the plug-in from the Downloads area, to install unzip the file, which should leave you with Salesforce_com.tmbundle and move it to ~/Library/Application Support/TextMate/Bundles and enjoy. 4 | 5 | ## Not under active development any more. Feel free to fork & modify, or checkout Mavensmate instead. 6 | -------------------------------------------------------------------------------- /apexLoader/common/Login.nib/info.nib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IBDocumentLocation 6 | 864 597 356 240 0 0 2560 1578 7 | IBFramework Version 8 | 446.1 9 | IBOpenObjects 10 | 11 | 7 12 | 65 13 | 14 | IBSystem Version 15 | 8L2127 16 | 17 | 18 | -------------------------------------------------------------------------------- /plugin/Commands/new run tests.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" runTests "$TM_SELECTED_TEXT" 9 | input 10 | none 11 | name 12 | Run Tests 13 | output 14 | showAsHTML 15 | uuid 16 | F5A6E83D-6A06-41F2-AAA2-B4C2A0AADC49 17 | 18 | 19 | -------------------------------------------------------------------------------- /plugin/Commands/Deploy Apex Page.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" apexpage "$TM_FILEPATH" 9 | input 10 | none 11 | name 12 | Deploy Apex Page 13 | output 14 | showAsHTML 15 | uuid 16 | 7790AEF2-2FE8-4EAA-B5B2-50C0CFBF9CEB 17 | 18 | 19 | -------------------------------------------------------------------------------- /plugin/Commands/new compile trigger.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" trigger "$TM_FILEPATH" 9 | input 10 | none 11 | name 12 | Compile Trigger 13 | output 14 | showAsHTML 15 | uuid 16 | E7F46294-6063-4EE7-BA26-3FDE4CBFD518 17 | 18 | 19 | -------------------------------------------------------------------------------- /plugin/Commands/new exec anon.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" execAnon "$TM_FILEPATH" 9 | 10 | fallbackInput 11 | document 12 | input 13 | none 14 | name 15 | Execute Anonymous 16 | output 17 | showAsHTML 18 | uuid 19 | 960EE079-5864-4B17-8E0C-D5225F2AB6E4 20 | 21 | 22 | -------------------------------------------------------------------------------- /plugin/Commands/c1.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | # just to remind you of some useful environment variables 9 | # see Help / Environment Variables for the full list 10 | #echo File: "$TM_FILEPATH" 11 | #echo Word: "$TM_CURRENT_WORD" 12 | #echo Selection: "$TM_SELECTED_TEXT" 13 | 14 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" setCredentials 15 | 16 | input 17 | none 18 | name 19 | Login 20 | output 21 | discard 22 | uuid 23 | CD0CF43E-5B9C-4BCF-9A19-4B2DB9D62CE9 24 | 25 | 26 | -------------------------------------------------------------------------------- /plugin/Commands/c2.tmCommand: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | beforeRunningCommand 6 | saveActiveFile 7 | command 8 | # just to remind you of some useful environment variables 9 | # see Help / Environment Variables for the full list 10 | #echo File: "$TM_FILEPATH" 11 | #echo Word: "$TM_CURRENT_WORD" 12 | #echo Selection: "$TM_SELECTED_TEXT" 13 | 14 | "$TM_BUNDLE_SUPPORT/bin/apexLoader.app/Contents/MacOS/apexLoader" package "$TM_FILEPATH" 15 | input 16 | none 17 | name 18 | Compile Class 19 | output 20 | showAsHTML 21 | uuid 22 | 0B35AD67-62C1-496C-A212-1C4784731E27 23 | 24 | 25 | -------------------------------------------------------------------------------- /plugin/Support/bin/ApexLoader.app/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ApexLoader 9 | CFBundleIdentifier 10 | com.yourcompany.ApexLoader 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | ApexLoader 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1.1 21 | NSMainNibFile 22 | MainMenu 23 | NSPrincipalClass 24 | NSApplication 25 | 26 | 27 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | com.yourcompany.ApexLoader 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.1 23 | NSMainNibFile 24 | MainMenu 25 | NSPrincipalClass 26 | NSApplication 27 | 28 | 29 | -------------------------------------------------------------------------------- /apexLoader/common/Login.nib/classes.nib: -------------------------------------------------------------------------------- 1 | { 2 | IBClasses = ( 3 | {CLASS = Credential; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 4 | {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 5 | { 6 | ACTIONS = { 7 | addNewServer = id; 8 | cancelLogin = id; 9 | closeAddNewServer = id; 10 | deleteServer = id; 11 | login = id; 12 | showAddNewServer = id; 13 | }; 14 | CLASS = ZKLoginController; 15 | LANGUAGE = ObjC; 16 | OUTLETS = { 17 | addButton = NSButton; 18 | delButton = NSButton; 19 | loginProgress = NSProgressIndicator; 20 | newUrlWindow = NSWindow; 21 | target = id; 22 | window = NSWindow; 23 | }; 24 | SUPERCLASS = NSObject; 25 | } 26 | ); 27 | IBVersion = 1; 28 | } -------------------------------------------------------------------------------- /plugin/info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | mainMenu 6 | 7 | items 8 | 9 | 0B35AD67-62C1-496C-A212-1C4784731E27 10 | E7F46294-6063-4EE7-BA26-3FDE4CBFD518 11 | F5A6E83D-6A06-41F2-AAA2-B4C2A0AADC49 12 | 960EE079-5864-4B17-8E0C-D5225F2AB6E4 13 | ------------------------------------ 14 | CD0CF43E-5B9C-4BCF-9A19-4B2DB9D62CE9 15 | 16 | submenus 17 | 18 | 19 | name 20 | Salesforce.com 21 | ordering 22 | 23 | C4D3A5F4-B1DE-48C5-84CE-AC99DDA78292 24 | CD0CF43E-5B9C-4BCF-9A19-4B2DB9D62CE9 25 | 0B35AD67-62C1-496C-A212-1C4784731E27 26 | E7F46294-6063-4EE7-BA26-3FDE4CBFD518 27 | F5A6E83D-6A06-41F2-AAA2-B4C2A0AADC49 28 | 960EE079-5864-4B17-8E0C-D5225F2AB6E4 29 | 30 | uuid 31 | D0ACF90F-D30A-4D1C-8D7A-FFF383CB5D4C 32 | 33 | 34 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkBaseClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | 25 | 26 | @interface ZKBaseClient : NSObject { 27 | NSString *endpointUrl; 28 | } 29 | 30 | - (NSXMLNode *)sendRequest:(NSString *)payload; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/ApexLoader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | 24 | @class Options; 25 | @class ZKLoginController; 26 | 27 | @interface ApexLoader : NSObject { 28 | ZKLoginController *login; 29 | Options *options; 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSaveResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkXmlDeserializer.h" 25 | 26 | @interface ZKSaveResult : ZKXmlDeserializer { 27 | } 28 | 29 | - (NSString *)id; 30 | - (BOOL)success; 31 | - (NSString *)statusCode; 32 | - (NSString *)message; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSoapException.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | 24 | 25 | @interface ZKSoapException : NSException { 26 | NSString * faultCode; 27 | } 28 | 29 | + (id) exceptionWithFaultCode:(NSString *)fc faultString:(NSString *)fs; 30 | 31 | - (NSString *)faultCode; 32 | - (void)setFaultCode:(NSString *)faultCode; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKPartnerEnvelope.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "ZKEnvelope.h" 24 | 25 | @interface ZKPartnerEnvelope : ZKEnvelope { 26 | } 27 | 28 | - (id)initWithSessionHeader:(NSString *)sessionId clientId:(NSString *)clientId; 29 | - (id)initWithSessionAndMruHeaders:(NSString *)sessionId mru:(BOOL)mru clientId:(NSString *)clientId; 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/Loader.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "Options.h" 24 | 25 | @class ZKSforceClient; 26 | @class ZKApexClient; 27 | 28 | @interface Loader : NSObject { 29 | ZKSforceClient *sforce; 30 | ZKApexClient *apex; 31 | Operation operation; 32 | } 33 | 34 | - (id)initWithSforce:(ZKSforceClient *)sforce; 35 | 36 | - (int) performOperation:(Options *)op; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeLocation.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKCodeLocation.h" 23 | 24 | 25 | @implementation ZKCodeLocation 26 | 27 | - (int)column { 28 | return [self integer:@"column"]; 29 | } 30 | 31 | - (int)line { 32 | return [self integer:@"line"]; 33 | } 34 | 35 | - (int)numExecutions { 36 | return [self integer:@"numExecutions"]; 37 | } 38 | 39 | - (double)time { 40 | return [self double:@"time"]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeCoverageWarning.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKCodeCoverageWarning.h" 23 | 24 | 25 | @implementation ZKCodeCoverageWarning 26 | 27 | -(NSString *)id { 28 | return [self string:@"id"]; 29 | } 30 | 31 | -(NSString *)message { 32 | return [self string:@"message"]; 33 | } 34 | 35 | -(NSString *)name { 36 | return [self string:@"name"]; 37 | } 38 | 39 | -(NSString *)namespace { 40 | return [self string:@"namespace"]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRecordTypeInfo.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKRecordTypeInfo.h" 23 | 24 | 25 | @implementation ZKRecordTypeInfo 26 | 27 | - (BOOL)available { 28 | return [self boolean:@"available"]; 29 | } 30 | - (BOOL)defaultRecordTypeMapping { 31 | return [self boolean:@"defaultRecordTypeMapping"]; 32 | } 33 | - (NSString *)name { 34 | return [self string:@"name"]; 35 | } 36 | - (NSString *)recordTypeId { 37 | return [self string:@"recordTypeId"]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKPicklistEntry.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKPicklistEntry.h" 23 | 24 | @implementation ZKPicklistEntry 25 | - (BOOL)active { 26 | return [self boolean:@"active"]; 27 | } 28 | - (BOOL)defaultValue { 29 | return [self boolean:@"defaultValue"]; 30 | } 31 | - (NSString *)label { 32 | return [self string:@"label"]; 33 | } 34 | - (NSString *)validFor { 35 | return [self string:@"validFor"]; 36 | } 37 | - (NSString *)value { 38 | return [self string:@"value"]; 39 | } 40 | @end 41 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSforce.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | // this just imports everything else that's you'll need access to, to make 24 | // it easy to pull in everything you might need. you can use this, or just 25 | // import the bits you care about. 26 | 27 | #import "zkSforceClient.h" 28 | #import "zkUserInfo.h" 29 | #import "zkSObject.h" 30 | #import "zkSoapException.h" 31 | #import "zkSaveResult.h" 32 | #import "zkQueryResult.h" 33 | #import "zkDescribeSObject.h" 34 | #import "zkDescribeField.h" 35 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeLocation.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | 30 | @interface ZKCodeLocation : ZKXmlDeserializer { 31 | } 32 | 33 | - (int)column; 34 | - (int)line; 35 | - (int)numExecutions; 36 | - (double)time; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkChildRelationship.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkChildRelationship.h" 24 | 25 | @implementation ZKChildRelationship 26 | 27 | -(BOOL)cascadeDelete { 28 | return [self boolean:@"cascadeDelete"]; 29 | } 30 | 31 | -(NSString *)childSObject { 32 | return [self string:@"childSObject"]; 33 | } 34 | 35 | -(NSString *)field { 36 | return [self string:@"field"]; 37 | } 38 | 39 | -(NSString *)relationshipName { 40 | return [self string:@"relationshipName"]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRunTestSuccess.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | #import "ZKRunTestSuccess.h" 22 | 23 | 24 | @implementation ZKRunTestSuccess 25 | 26 | -(NSString *)id { 27 | return [self string:@"id"]; 28 | } 29 | 30 | -(NSString *)methodName { 31 | return [self string:@"methodName"]; 32 | } 33 | 34 | -(NSString *)name { 35 | return [self string:@"name"]; 36 | } 37 | 38 | -(NSString *)namespace { 39 | return [self string:@"namespace"]; 40 | } 41 | 42 | -(double)time { 43 | return [self double:@"time"]; 44 | } 45 | 46 | @end 47 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRunTestFailure.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKRunTestFailure.h" 23 | 24 | 25 | @implementation ZKRunTestFailure 26 | 27 | - (NSString *)message { 28 | return [self string:@"message"]; 29 | } 30 | 31 | - (NSString *)namespace { 32 | return [self string:@"namespace"]; 33 | } 34 | 35 | - (NSString *)packageName { 36 | return [self string:@"packageName"]; 37 | } 38 | 39 | - (NSString *)methodName { 40 | return [self string:@"methodName"]; 41 | } 42 | 43 | - (NSString *)stackTrace { 44 | return [self string:@"stackTrace"]; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/Options.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | 24 | typedef enum Operation { 25 | opTriggers = 1, 26 | opPackages, 27 | opRunTests, 28 | opExecAnon, 29 | opSetKeychain, 30 | opApexPages 31 | } Operation; 32 | 33 | typedef enum LogLevel { 34 | logError = 1, 35 | logWarning, 36 | logVerbose 37 | } LogLevel; 38 | 39 | @interface Options : NSObject { 40 | NSString *filename; 41 | Operation operation; 42 | } 43 | 44 | - (BOOL)parseArguments:(NSArray *)args; 45 | - (NSString *)filename; 46 | - (Operation)operation; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeCoverageWarning.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | 26 | /* 27 | 28 | 29 | 30 | 31 | 32 | 33 | */ 34 | @interface ZKCodeCoverageWarning : ZKXmlDeserializer { 35 | } 36 | 37 | -(NSString *)id; 38 | -(NSString *)message; 39 | -(NSString *)name; 40 | -(NSString *)namespace; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRunTestFailure.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | // 30 | 31 | @interface ZKRunTestFailure : ZKXmlDeserializer { 32 | } 33 | 34 | - (NSString *)message; 35 | - (NSString *)namespace; 36 | - (NSString *)packageName; 37 | - (NSString *)methodName; 38 | - (NSString *)stackTrace; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkApexClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkSforceClient.h" 24 | 25 | @class ZKExecuteAnonymousResult; 26 | @class ZKRunTestResult; 27 | 28 | @interface ZKApexClient : ZKBaseClient { 29 | ZKSforceClient *sforce; 30 | } 31 | 32 | + (id) fromClient:(ZKSforceClient *)sf; 33 | - (id) initFromClient:(ZKSforceClient *)sf; 34 | 35 | - (NSArray *)compilePackages:(NSArray *)src; 36 | - (NSArray *)compileTriggers:(NSArray *)src; 37 | - (ZKExecuteAnonymousResult *)executeAnonymous:(NSString *)src; 38 | - (ZKRunTestResult *)runTests:(BOOL)allTests namespace:(NSString *)ns packages:(NSArray *)pkgs; 39 | @end 40 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkXmlDeserializer.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | 25 | @interface ZKXmlDeserializer : NSObject { 26 | NSXMLElement *node; 27 | NSMutableDictionary *values; 28 | } 29 | - (id)initWithXmlElement:(NSXMLElement *)e; 30 | 31 | - (NSString *)string:(NSString *)elem; 32 | - (BOOL)boolean:(NSString *)elem; 33 | - (int)integer:(NSString *)elem; 34 | - (double)double:(NSString *)elem; 35 | - (NSArray *)strings:(NSString *)elem; 36 | 37 | - (NSString *)string:(NSString *)elemName fromXmlElement:(NSXMLElement*)xmlElement; 38 | - (NSArray *)complexTypeArrayFromElements:(NSString *)elemName cls:(Class)type; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRunTestSuccess.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | /* 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | */ 34 | @interface ZKRunTestSuccess : ZKXmlDeserializer { 35 | } 36 | 37 | -(NSString *)id; 38 | -(NSString *)methodName; 39 | -(NSString *)name; 40 | -(NSString *)namespace; 41 | -(double)time; 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSoapException.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkSoapException.h" 24 | 25 | 26 | @implementation ZKSoapException 27 | 28 | + (id)exceptionWithFaultCode:(NSString *)fc faultString:(NSString *)fs { 29 | id ex = [ZKSoapException exceptionWithName:fc reason:fs userInfo:nil]; 30 | [ex setFaultCode:fc]; 31 | return ex; 32 | } 33 | 34 | - (void)dealloc { 35 | [faultCode release]; 36 | [super dealloc]; 37 | } 38 | 39 | - (NSString *)faultCode { 40 | return faultCode; 41 | } 42 | 43 | - (void)setFaultCode:(NSString *)fc { 44 | if (faultCode == fc) return; 45 | [faultCode release]; 46 | faultCode = [fc retain]; 47 | } 48 | 49 | @end 50 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKPartnerEnvelope.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKPartnerEnvelope.h" 23 | 24 | @implementation ZKPartnerEnvelope 25 | 26 | - (id)initWithSessionHeader:(NSString *)sessionId clientId:(NSString *)clientId { 27 | return [self initWithSessionAndMruHeaders:sessionId mru:NO clientId:clientId]; 28 | } 29 | 30 | - (id)initWithSessionAndMruHeaders:(NSString *)sessionId mru:(BOOL)mru clientId:(NSString *)clientId { 31 | self = [super init]; 32 | [self start:@"urn:partner.soap.sforce.com"]; 33 | [self writeSessionHeader:sessionId]; 34 | [self writeCallOptionsHeader:clientId]; 35 | [self writeMruHeader:mru]; 36 | [self moveToBody]; 37 | return self; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkExecuteAnonResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "zkExecuteAnonResult.h" 23 | 24 | @implementation ZKExecuteAnonymousResult 25 | 26 | - (int)column { 27 | return [self integer:@"column"]; 28 | } 29 | - (int)line { 30 | return [self integer:@"line"]; 31 | } 32 | - (BOOL)compiled { 33 | return [self boolean:@"compiled"]; 34 | } 35 | - (NSString *)compileProblem { 36 | return [self string:@"compileProblem"]; 37 | } 38 | - (NSString *)exceptionMessage { 39 | return [self string:@"exceptionMessage"]; 40 | } 41 | - (NSString *)exceptionStackTrace { 42 | return [self string:@"exceptionStackTrace"]; 43 | } 44 | - (BOOL)success { 45 | return [self boolean:@"success"]; 46 | } 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkChildRelationship.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | 34 | @interface ZKChildRelationship : ZKXmlDeserializer { 35 | } 36 | 37 | -(BOOL)cascadeDelete; 38 | -(NSString *)childSObject; 39 | -(NSString *)field; 40 | -(NSString *)relationshipName; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkQueryResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | 24 | @interface ZKQueryResult : NSObject { 25 | int size; 26 | BOOL done; 27 | NSString * queryLocator; 28 | NSArray * records; 29 | } 30 | 31 | - (id)initFromXmlNode:(NSXMLNode *)node; 32 | - (id)initWithRecords:(NSArray *)records size:(int)s done:(BOOL)d queryLocator:(NSString *)ql; 33 | 34 | - (int)size; 35 | - (BOOL)done; 36 | - (NSString *)queryLocator; 37 | - (NSArray *)records; 38 | 39 | // make it compaitble with the data source for a table 40 | - (int)numberOfRowsInTableView:(NSTableView *)v; 41 | - (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)tc row:(int)rowIdx; 42 | @end 43 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkRunTestResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | 30 | @interface ZKRunTestResult : ZKXmlDeserializer { 31 | } 32 | 33 | - (NSArray *)codeCoverage; 34 | - (NSArray *)failures; 35 | - (int)numFailures; 36 | - (int)numTestsRun; 37 | 38 | - (NSArray *)codeCoverageWarnings; 39 | - (NSArray *)successes; 40 | - (double)totalTime; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkUserInfo.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkXmlDeserializer.h" 25 | 26 | @interface ZKUserInfo : ZKXmlDeserializer { 27 | } 28 | 29 | // API v7.0 30 | -(BOOL)accessibilityMode; 31 | -(NSString *)currencySymbol; 32 | -(NSString *)organizationId; 33 | -(NSString *)organizationName; 34 | -(BOOL)organizationIsMultiCurrency; 35 | -(NSString *)defaultCurrencyIsoCode; 36 | -(NSString *)email; 37 | -(NSString *)fullName; 38 | -(NSString *)userId; 39 | -(NSString *)language; 40 | -(NSString *)locale; 41 | -(NSString *)timeZone; 42 | -(NSString *)skin; 43 | // API v8.0 44 | -(NSString *)licenseType; 45 | -(NSString *)profileId; 46 | -(NSString *)roleId; 47 | -(NSString *)userName; 48 | @end 49 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCompileResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKCompileResult.h" 23 | 24 | 25 | @implementation ZKCompileResult 26 | 27 | -(NSString *)userName { 28 | return [self string:@"userName"]; 29 | } 30 | 31 | - (BOOL)success { 32 | return [self boolean:@"success"]; 33 | } 34 | 35 | - (NSString *)id { 36 | return [self string:@"id"]; 37 | } 38 | 39 | - (NSString *)problem { 40 | return [self string:@"problem"]; 41 | } 42 | 43 | - (int)bodyCrc { 44 | return [self integer:@"bodyCrc"]; 45 | } 46 | 47 | - (int)column { 48 | return [self integer:@"column"]; 49 | } 50 | 51 | - (int)line { 52 | return [self integer:@"line"]; 53 | } 54 | 55 | - (NSString *)name { 56 | return [self string:@"name"]; 57 | } 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKPicklistEntry.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkXmlDeserializer.h" 25 | 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | // 34 | // 35 | 36 | @interface ZKPicklistEntry : ZKXmlDeserializer { 37 | } 38 | - (BOOL)active; 39 | - (BOOL)defaultValue; 40 | - (NSString *)label; 41 | - (NSString *)validFor; 42 | - (NSString *)value; 43 | @end 44 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkExecuteAnonResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | 33 | @interface ZKExecuteAnonymousResult : ZKXmlDeserializer { 34 | } 35 | 36 | - (int)column; 37 | - (int)line; 38 | - (BOOL)compiled; 39 | - (NSString *)compileProblem; 40 | - (NSString *)exceptionMessage; 41 | - (NSString *)exceptionStackTrace; 42 | - (BOOL)success; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSaveResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkSaveResult.h" 24 | 25 | @implementation ZKSaveResult 26 | 27 | - (NSString *)id { 28 | return [self string:@"id"]; 29 | } 30 | 31 | - (BOOL)success { 32 | return [self boolean:@"success"]; 33 | } 34 | 35 | - (NSString *)statusCode { 36 | if ([self success]) return nil; 37 | return [self string:@"statusCode" fromXmlElement:[[node elementsForName:@"errors"] objectAtIndex:0]]; 38 | } 39 | 40 | - (NSString *)message { 41 | if ([self success]) return nil; 42 | return [self string:@"message" fromXmlElement:[[node elementsForName:@"errors"] objectAtIndex:0]]; 43 | } 44 | 45 | - (NSString *)description { 46 | if ([self success]) 47 | return [self id]; 48 | return [NSString stringWithFormat:@"%@ - %@", [self statusCode], [self message]]; 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKRecordTypeInfo.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkXmlDeserializer.h" 25 | 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | // 34 | 35 | @interface ZKRecordTypeInfo : ZKXmlDeserializer { 36 | } 37 | - (BOOL)available; 38 | - (BOOL)defaultRecordTypeMapping; 39 | - (NSString *)name; 40 | - (NSString *)recordTypeId; 41 | @end 42 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCompileResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | // 34 | // 35 | 36 | @interface ZKCompileResult : ZKXmlDeserializer { 37 | } 38 | 39 | - (BOOL)success; 40 | - (NSString *)id; 41 | - (NSString *)problem; 42 | - (int)bodyCrc; 43 | - (int)column; 44 | - (int)line; 45 | - (NSString *)name; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkEnvelope.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkSObject.h" 25 | 26 | @interface ZKEnvelope : NSObject { 27 | NSMutableString *env; 28 | int state; 29 | } 30 | 31 | - (void)start:(NSString *)primaryNamespceUri; 32 | - (void)writeSessionHeader:(NSString *)sessionId; 33 | - (void)writeCallOptionsHeader:(NSString *)callOptions; 34 | - (void)writeMruHeader:(BOOL)updateMru; 35 | 36 | - (void) moveToBody; 37 | - (void) startElement:(NSString *)elemName; 38 | - (void) endElement:(NSString *)elemName; 39 | - (void) writeText:(NSString *)text; 40 | - (void) addElement:(NSString *)elemName elemValue:(id)elemValue; 41 | - (NSString *)end; 42 | 43 | - (void) addElementArray:(NSString *)elemName elemValue:(NSArray *)elemValues; 44 | - (void) addElementSObject:(NSString *)elemName elemValue:(ZKSObject *)sobject; 45 | - (void) addElementString:(NSString *)elemName elemValue:(NSString *)elemValue; 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkRunTestResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "zkRunTestResult.h" 23 | #import "zkRunTestFailure.h" 24 | #import "zkCodeCoverageResult.h" 25 | #import "ZKCodeCoverageWarning.h" 26 | #import "ZKRunTestSuccess.h" 27 | 28 | @implementation ZKRunTestResult 29 | 30 | - (NSArray *)codeCoverage { 31 | return [self complexTypeArrayFromElements:@"codeCoverage" cls:[ZKCodeCoverageResult class]]; 32 | } 33 | 34 | - (NSArray *)failures { 35 | return [self complexTypeArrayFromElements:@"failures" cls:[ZKRunTestFailure class]]; 36 | } 37 | 38 | - (int)numFailures { 39 | return [self integer:@"numFailures"]; 40 | } 41 | 42 | - (int)numTestsRun { 43 | return [self integer:@"numTestsRun"]; 44 | } 45 | 46 | - (NSArray *)codeCoverageWarnings { 47 | return [self complexTypeArrayFromElements:@"codeCoverageWarnings" cls:[ZKCodeCoverageWarning class]]; 48 | } 49 | 50 | - (NSArray *)successes { 51 | return [self complexTypeArrayFromElements:@"successes" cls:[ZKRunTestSuccess class]]; 52 | } 53 | 54 | - (double)totalTime { 55 | return [self double:@"totalTime"]; 56 | } 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeCoverageResult.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | 25 | // 26 | // 27 | // 28 | // 29 | // 30 | // 31 | // 32 | // 33 | // 34 | 35 | @interface ZKCodeCoverageResult : ZKXmlDeserializer { 36 | } 37 | 38 | - (NSArray *)dmlInfo; 39 | - (NSArray *)locationsNotCovered; 40 | - (NSArray *)methodInfo; 41 | - (NSString *)name; 42 | - (NSString *)namespace; 43 | - (int)numLocations; 44 | - (int)numLocationsNotCovered; 45 | - (NSArray *)soqlInfo; 46 | - (NSString *)type; 47 | 48 | - (NSString *)id; 49 | - (NSArray *)soslInfo; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/Options.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "Options.h" 23 | 24 | 25 | @implementation Options 26 | 27 | - (BOOL)parseArguments:(NSArray *)args { 28 | BOOL expectFn = YES; 29 | if ([args count] == 1) { 30 | operation = opSetKeychain; 31 | return TRUE; 32 | } 33 | NSString *p = [args objectAtIndex:1]; 34 | if ([p caseInsensitiveCompare:@"package"] == NSOrderedSame) 35 | operation = opPackages; 36 | else if ([p caseInsensitiveCompare:@"trigger"] == NSOrderedSame) 37 | operation = opTriggers; 38 | else if ([p caseInsensitiveCompare:@"apexpage"] == NSOrderedSame) 39 | operation = opApexPages; 40 | else if ([p caseInsensitiveCompare:@"runTests"] == NSOrderedSame) 41 | operation = opRunTests; 42 | else if ([p caseInsensitiveCompare:@"execAnon"] == NSOrderedSame) 43 | operation = opExecAnon; 44 | else if ([p caseInsensitiveCompare:@"setCredentials"] == NSOrderedSame) { 45 | operation = opSetKeychain; 46 | expectFn = NO; 47 | } 48 | if (expectFn) 49 | filename = [[args objectAtIndex:2] retain]; 50 | 51 | return TRUE; 52 | } 53 | 54 | - (void)dealloc { 55 | [filename release]; 56 | [super dealloc]; 57 | } 58 | 59 | - (NSString *)filename { 60 | return filename; 61 | } 62 | 63 | - (Operation)operation { 64 | return operation; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /apexLoader/sforce/ZKCodeCoverageResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2009 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKCodeCoverageResult.h" 23 | #import "ZKCodeLocation.h" 24 | 25 | @implementation ZKCodeCoverageResult 26 | 27 | - (NSArray *)dmlInfo { 28 | return [self complexTypeArrayFromElements:@"dmlInfo" cls:[ZKCodeLocation class]]; 29 | } 30 | 31 | - (NSArray *)locationsNotCovered { 32 | return [self complexTypeArrayFromElements:@"locationsNotCovered" cls:[ZKCodeLocation class]]; 33 | } 34 | 35 | - (NSArray *)methodInfo { 36 | return [self complexTypeArrayFromElements:@"methodInfo" cls:[ZKCodeLocation class]]; 37 | } 38 | 39 | - (NSString *)name { 40 | return [self string:@"name"]; 41 | } 42 | 43 | - (NSString *)namespace { 44 | return [self string:@"namespace"]; 45 | } 46 | 47 | - (int)numLocations { 48 | return [self integer:@"numLocations"]; 49 | } 50 | 51 | - (int)numLocationsNotCovered { 52 | return [self integer:@"numLocationsNotCovered"]; 53 | } 54 | 55 | - (NSArray *)soqlInfo { 56 | return [self complexTypeArrayFromElements:@"soqlInfo" cls:[ZKCodeLocation class]]; 57 | } 58 | 59 | - (NSString *)type { 60 | return [self string:@"type"]; 61 | } 62 | 63 | - (NSString *)id { 64 | return [self string:@"id"]; 65 | } 66 | 67 | - (NSArray *)soslInfo { 68 | return [self complexTypeArrayFromElements:@"soslInfo" cls:[ZKCodeLocation class]]; 69 | } 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /apexLoader/common/credential.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #include 24 | 25 | 26 | @interface Credential : NSObject { 27 | NSString *server; 28 | NSString *username; 29 | SecKeychainItemRef keychainItem; 30 | } 31 | 32 | + (NSArray *)credentialsForServer:(NSString *)protocolAndServer; 33 | + (NSArray *)sortedCredentialsForServer:(NSString *)protocolAndServer; 34 | 35 | + (id)forServer:(NSString *)server username:(NSString *)un keychainItem:(SecKeychainItemRef)kcItem; 36 | + (id)createCredentialForServer:(NSString *)protocolAndServer username:(NSString *)un password:(NSString *)pwd; 37 | 38 | - (id)initForServer:(NSString *)server username:(NSString *)un keychainItem:(SecKeychainItemRef)kcItem; 39 | 40 | - (NSString *)server; 41 | - (NSString *)username; 42 | - (NSString *)password; 43 | - (NSString *)comment; 44 | - (NSString *)creator; 45 | - (BOOL)canReadPasswordWithoutPrompt; 46 | 47 | - (void)setServer:(NSString *)newServer; 48 | - (void)setUsername:(NSString *)newUsername; 49 | - (void)setPassword:(NSString *)newPassword; 50 | - (void)setComment:(NSString *)newComment; 51 | - (void)setCreator:(NSString *)newCreator; 52 | 53 | - (void)removeFromKeychain; 54 | - (OSStatus)update:(NSString *)username password:(NSString *)password; 55 | @end 56 | 57 | @interface NSURL (Keychain) 58 | - (SecProtocolType)SecProtocolType; 59 | @end -------------------------------------------------------------------------------- /apexLoader/sforce/zkSObject.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkQueryResult.h" 24 | 25 | NSString * NS_URI_XSI; 26 | 27 | @interface ZKSObject : NSObject { 28 | NSString *Id; 29 | NSString *type; 30 | NSMutableSet *fieldsToNull; 31 | NSMutableDictionary *fields; 32 | } 33 | 34 | + (id) withType:(NSString *)type; 35 | + (id) withTypeAndId:(NSString *)type sfId:(NSString *)sfId; 36 | + (id) fromXmlNode:(NSXMLNode *)node; 37 | 38 | - (id) initFromXmlNode:(NSXMLNode *)node; 39 | - (id) initWithType:(NSString *)type; 40 | 41 | // setters 42 | - (void)setId:(NSString *)theId; 43 | // setting a fieldValue to nil will automatically put it in the fieldsToNull collection 44 | // setting a fieldValue to non nil will automatically remove it from the fieldsToNull collection 45 | - (void)setFieldValue:(NSString *)value field:(NSString *)field; 46 | - (void)setFieldDateTimeValue:(NSCalendarDate *)value field:(NSString *)field; 47 | - (void)setFieldDateValue:(NSCalendarDate *)value field:(NSString *)field; 48 | - (void)setFieldToNull:(NSString *)field; 49 | 50 | // basic getters 51 | - (NSString *)id; 52 | - (NSString *)type; 53 | - (NSArray *)fieldsToNull; 54 | - (NSDictionary *)fields; 55 | - (id)fieldValue:(NSString *)field; 56 | - (BOOL)isFieldToNull:(NSString *)field; 57 | 58 | // typed getters 59 | - (BOOL)boolValue:(NSString *)field; 60 | - (NSCalendarDate *)dateTimeValue:(NSString *)field; 61 | - (NSCalendarDate *)dateValue:(NSString *)field; 62 | - (int)intValue:(NSString *)field; 63 | - (double)doubleValue:(NSString *)field; 64 | - (ZKQueryResult *)queryResultValue:(NSString *)field; 65 | @end 66 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkBaseClient.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "zkBaseClient.h" 23 | #import "zkSoapException.h" 24 | 25 | @implementation ZKBaseClient 26 | 27 | - (void)dealloc { 28 | [endpointUrl release]; 29 | [super dealloc]; 30 | } 31 | 32 | - (NSXMLNode *)sendRequest:(NSString *)payload { 33 | NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:endpointUrl]]; 34 | [request setHTTPMethod:@"POST"]; 35 | [request addValue:@"text/xml; charset=UTF-8" forHTTPHeaderField:@"content-type"]; 36 | [request addValue:@"\"\"" forHTTPHeaderField:@"SOAPAction"]; 37 | 38 | NSData *data = [payload dataUsingEncoding:NSUTF8StringEncoding]; 39 | [request setHTTPBody:data]; 40 | 41 | NSHTTPURLResponse *resp = nil; 42 | NSError *err = nil; 43 | // todo, support request compression 44 | // todo, support response compression 45 | NSData *respPayload = [NSURLConnection sendSynchronousRequest:request returningResponse:&resp error:&err]; 46 | NSXMLDocument *doc = [[[NSXMLDocument alloc] initWithData:respPayload options:NSXMLNodeOptionsNone error:&err] autorelease]; 47 | if (err != NULL) { 48 | @throw [NSException exceptionWithName:@"Xml error" reason:@"Unable to parse XML returned by server" userInfo:nil]; 49 | } 50 | if (500 == [resp statusCode]) { 51 | NSXMLNode * nFaultCode = [[doc nodesForXPath:@"/soapenv:Envelope/soapenv:Body/soapenv:Fault/faultcode" error:&err] objectAtIndex:0]; 52 | NSXMLNode * nFaultMsg = [[doc nodesForXPath:@"/soapenv:Envelope/soapenv:Body/soapenv:Fault/faultstring" error:&err] objectAtIndex:0]; 53 | ZKSoapException *exception = [ZKSoapException exceptionWithFaultCode:[nFaultCode stringValue] faultString:[nFaultMsg stringValue]]; 54 | @throw exception; 55 | } 56 | NSXMLNode *body = [[doc nodesForXPath:@"/soapenv:Envelope/soapenv:Body" error:&err] objectAtIndex:0]; 57 | return [[body children] objectAtIndex:0]; 58 | } 59 | 60 | @end 61 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSforceClient.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkBaseClient.h" 25 | 26 | @class ZKUserInfo; 27 | @class ZKDescribeSObject; 28 | @class ZKQueryResult; 29 | 30 | @interface ZKSforceClient : ZKBaseClient { 31 | NSString *authEndpointUrl; 32 | NSString *username; 33 | NSString *password; 34 | NSString *clientId; 35 | NSString *sessionId; 36 | NSDate *sessionExpiresAt; 37 | BOOL updateMru; 38 | ZKUserInfo *userInfo; 39 | BOOL cacheDescribes; 40 | NSMutableDictionary *describes; 41 | } 42 | 43 | // configuration 44 | - (void)setLoginProtocolAndHost:(NSString *)protocolAndHost; 45 | - (void)setLoginProtocolAndHost:(NSString *)protocolAndHost andVersion:(int)version; 46 | 47 | // all map directly to Sforce API calls 48 | - (void)login:(NSString *)username password:(NSString *)password; 49 | - (NSArray *)describeGlobal; 50 | - (ZKDescribeSObject *)describeSObject:(NSString *)sobjectName; 51 | - (NSArray *)search:(NSString *)sosl; 52 | - (ZKQueryResult *)query:(NSString *)soql; 53 | - (ZKQueryResult *)queryAll:(NSString *)soql; 54 | - (ZKQueryResult *)queryMore:(NSString *)queryLocator; 55 | - (NSDictionary *)retrieve:(NSString *)fields sobject:(NSString *)sobjectType ids:(NSArray *)ids; 56 | - (NSArray *)create:(NSArray *)objects; 57 | - (NSArray *)update:(NSArray *)objects; 58 | - (NSArray *)upsert:(NSString *)extIdFieldName objects:(NSArray *)objects; 59 | - (NSArray *)delete:(NSArray *)ids; 60 | - (NSString *)serverTimestamp; 61 | 62 | // status info 63 | - (BOOL)loggedIn; 64 | - (ZKUserInfo *)currentUserInfo; 65 | - (NSString *)serverUrl; 66 | - (NSString *)sessionId; 67 | 68 | // headers 69 | - (BOOL)updateMru; 70 | - (void)setUpdateMru:(BOOL)aValue; 71 | - (NSString *)clientId; 72 | - (void)setClientId:(NSString *)aClientId; 73 | 74 | 75 | // describe caching 76 | - (BOOL)cacheDescribes; 77 | - (void)setCacheDescribes:(BOOL)newCacheDescribes; 78 | - (void)flushCachedDescribes; 79 | @end 80 | -------------------------------------------------------------------------------- /apexLoader/common/ZKLoginController.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | // LoginController and Login.nib make a reusable login window that support 23 | // the keychain, multiple servers, and differing ways to open the window 24 | #import 25 | 26 | @class Credential; 27 | @class ZKSforceClient; 28 | @class ZKSoapException; 29 | 30 | @interface ZKLoginController : NSObject { 31 | NSString *username; 32 | NSString *password; 33 | NSString *server; 34 | NSString *clientId; 35 | NSArray *credentials; 36 | Credential *selectedCredential; 37 | ZKSforceClient *sforce; 38 | NSString *newUrl; 39 | NSString *statusText; 40 | 41 | NSWindow *modalWindow; 42 | id target; 43 | SEL selector; 44 | IBOutlet NSWindow *window; 45 | IBOutlet NSButton *addButton; 46 | IBOutlet NSButton *delButton; 47 | IBOutlet NSWindow *newUrlWindow; 48 | IBOutlet NSProgressIndicator *loginProgress; 49 | } 50 | 51 | - (ZKSforceClient *)showModalLoginWindow:(id)sender; 52 | - (void)showLoginWindow:(id)sender target:(id)target selector:(SEL)selector; 53 | - (void)showLoginSheet:(NSWindow *)modalForWindow target:(id)target selector:(SEL)selector; 54 | 55 | - (IBAction)cancelLogin:(id)sender; 56 | - (IBAction)login:(id)sender; 57 | - (IBAction)showAddNewServer:(id)sender; 58 | - (IBAction)closeAddNewServer:(id)sender; 59 | - (IBAction)addNewServer:(id)sender; 60 | - (IBAction)deleteServer:(id)sender; 61 | 62 | - (NSString *)username; 63 | - (void)setUsername:(NSString *)aUsername; 64 | - (NSString *)password; 65 | - (void)setPassword:(NSString *)aPassword; 66 | - (NSString *)server; 67 | - (void)setServer:(NSString *)aServer; 68 | - (NSArray *)credentials; 69 | - (NSString *)newUrl; 70 | - (void)setNewUrl:(NSString *)aNewUrl; 71 | - (NSString *)statusText; 72 | - (void)setStatusText:(NSString *)aStatusText; 73 | - (BOOL)canDeleteServer; 74 | - (NSString *)clientId; 75 | - (void)setClientId:(NSString *)aClientId; 76 | - (void)setClientIdFromInfoPlist; 77 | - (ZKSforceClient *)performLogin:(ZKSoapException **)error; 78 | @end 79 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkXmlDeserializer.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "zkXmlDeserializer.h" 23 | 24 | @implementation ZKXmlDeserializer 25 | 26 | -(id)initWithXmlElement:(NSXMLElement *)e { 27 | self = [super init]; 28 | node = [e retain]; 29 | values = [[NSMutableDictionary alloc] init]; 30 | return self; 31 | } 32 | 33 | -(void)dealloc { 34 | [node release]; 35 | [values release]; 36 | [super dealloc]; 37 | } 38 | 39 | - (NSString *)string:(NSString *)elem { 40 | id cached = [values objectForKey:elem]; 41 | if (cached != nil) return cached == [NSNull null] ? nil : cached; 42 | id v = [self string:elem fromXmlElement:node]; 43 | [values setObject:(v != nil ? v : [NSNull null]) forKey:elem]; 44 | return v; 45 | } 46 | 47 | - (BOOL)boolean:(NSString *)elem { 48 | return [[self string:elem] isEqualToString:@"true"]; 49 | } 50 | 51 | - (int)integer:(NSString *)elem { 52 | return [[self string:elem] intValue]; 53 | } 54 | 55 | - (double)double:(NSString *)elem { 56 | return [[self string:elem] doubleValue]; 57 | } 58 | 59 | - (NSArray *)strings:(NSString *)elem { 60 | NSArray *cached = [values objectForKey:elem]; 61 | if (cached != nil) return cached; 62 | NSArray *nodes = [node elementsForName:elem]; 63 | NSMutableArray *s = [NSMutableArray arrayWithCapacity:[nodes count]]; 64 | NSXMLNode *n; 65 | NSEnumerator *e = [nodes objectEnumerator]; 66 | while (n = [e nextObject]) { 67 | [s addObject:[n stringValue]]; 68 | } 69 | [values setObject:s forKey:elem]; 70 | return s; 71 | } 72 | 73 | - (NSString *)string:(NSString *)elemName fromXmlElement:(NSXMLElement*)xmlElement { 74 | NSArray * nodes = [xmlElement elementsForName:elemName]; 75 | if ([nodes count] == 0) return nil; 76 | return [[nodes objectAtIndex:0] stringValue]; 77 | } 78 | 79 | - (NSArray *)complexTypeArrayFromElements:(NSString *)elemName cls:(Class)type { 80 | NSArray *cached = [values objectForKey:elemName]; 81 | if (cached == nil) { 82 | NSArray *elements = [node elementsForName:elemName]; 83 | NSMutableArray *results = [NSMutableArray arrayWithCapacity:[elements count]]; 84 | NSXMLElement * childNode; 85 | NSEnumerator *e = [elements objectEnumerator]; 86 | while (childNode = [e nextObject]) { 87 | NSObject *child = [[type alloc] initWithXmlElement:childNode]; 88 | [results addObject:child]; 89 | [child release]; 90 | } 91 | [values setObject:results forKey:elemName]; 92 | cached = results; 93 | } 94 | return cached; 95 | } 96 | 97 | @end 98 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkDescribeSObject.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import 23 | #import "zkXmlDeserializer.h" 24 | #import "zkDescribeField.h" 25 | 26 | /* 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | */ 51 | 52 | @interface ZKDescribeSObject : ZKXmlDeserializer { 53 | NSArray *fields; 54 | NSDictionary *fieldsByName; 55 | NSArray *childRelationships; 56 | NSArray *recordTypeInfos; 57 | } 58 | 59 | -(BOOL)activateable; 60 | -(BOOL)createable; 61 | -(BOOL)custom; 62 | -(BOOL)deletable; 63 | -(BOOL)layoutable; 64 | -(BOOL)mergeable; 65 | -(BOOL)queryable; 66 | -(BOOL)replicateable; 67 | -(BOOL)retrieveable; 68 | -(BOOL)searchable; 69 | -(BOOL)triggerable; 70 | -(BOOL)undeleteable; 71 | -(BOOL)updateable; 72 | -(NSString *)keyPrefix; 73 | -(NSString *)label; 74 | -(NSString *)labelPlural; 75 | -(NSString *)name; 76 | -(NSString *)urlDetail; 77 | -(NSString *)urlEdit; 78 | -(NSString *)urlNew; 79 | -(NSArray *)fields; 80 | -(ZKDescribeField *)fieldWithName:(NSString *)name; 81 | -(NSArray *)childRelationships; 82 | -(NSArray *)recordTypeInfos; 83 | @end 84 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkQueryResult.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkQueryResult.h" 24 | #import "zkSObject.h" 25 | 26 | @implementation ZKQueryResult 27 | 28 | - (id)initFromXmlNode:(NSXMLNode *)node { 29 | self = [super init]; 30 | int i = 0; 31 | NSError * err = NULL; 32 | size = [[[[node nodesForXPath:@"size" error:&err] objectAtIndex:0] stringValue] intValue]; 33 | NSString * strDone = [[[node nodesForXPath:@"done" error:&err] objectAtIndex:0] stringValue]; 34 | done = [strDone isEqualToString:@"true"]; 35 | if (done == NO) 36 | queryLocator = [[[[node nodesForXPath:@"queryLocator" error:&err] objectAtIndex:0] stringValue] copy]; 37 | 38 | NSArray * nodes = [node nodesForXPath:@"records" error:&err]; 39 | NSMutableArray * recArray = [NSMutableArray arrayWithCapacity:[nodes count]]; 40 | ZKSObject * o; 41 | for (i = 0; i < [nodes count]; i++) 42 | { 43 | NSXMLNode * n = [nodes objectAtIndex:i]; 44 | NSXMLNode *xsiNil = [(NSXMLElement*)n attributeForLocalName:@"nil" URI:NS_URI_XSI]; 45 | if (xsiNil != nil && [[xsiNil stringValue] isEqualToString:@"true"]) 46 | continue; 47 | o = [[ZKSObject alloc] initFromXmlNode:n]; 48 | [recArray addObject:o]; 49 | [o release]; 50 | } 51 | records = [recArray retain]; 52 | return self; 53 | } 54 | 55 | - (id)initWithRecords:(NSArray *)r size:(int)s done:(BOOL)d queryLocator:(NSString *)ql { 56 | self = [super init]; 57 | records = [r retain]; 58 | done = d; 59 | size = s; 60 | queryLocator = [ql retain]; 61 | return self; 62 | } 63 | 64 | - (id)copyWithZone:(NSZone *)zone { 65 | return [[ZKQueryResult alloc] initWithRecords:records size:size done:done queryLocator:queryLocator]; 66 | } 67 | 68 | - (void)dealloc { 69 | [queryLocator release]; 70 | [records release]; 71 | [super dealloc]; 72 | } 73 | 74 | - (int)size { 75 | return size; 76 | } 77 | 78 | - (BOOL)done { 79 | return done; 80 | } 81 | 82 | - (NSString *)queryLocator { 83 | return queryLocator; 84 | } 85 | 86 | - (NSArray *)records { 87 | return records; 88 | } 89 | 90 | - (int)numberOfRowsInTableView:(NSTableView *)v { 91 | return [records count]; 92 | } 93 | 94 | - (id)tableView:(NSTableView *)view objectValueForTableColumn:(NSTableColumn *)tc row:(int)rowIdx { 95 | NSArray *path = [[tc identifier] componentsSeparatedByString:@"."]; 96 | id val = [records objectAtIndex:rowIdx]; 97 | NSString *step; 98 | NSEnumerator *e = [path objectEnumerator]; 99 | while (step = [e nextObject]) { 100 | val = [val fieldValue:step]; 101 | } 102 | return val; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkUserInfo.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkUserInfo.h" 24 | 25 | @implementation ZKUserInfo 26 | 27 | /* 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | */ 46 | 47 | 48 | -(BOOL)accessibilityMode { 49 | return [self boolean:@"accessibilityMode"]; 50 | } 51 | -(NSString *)currencySymbol { 52 | return [self string:@"currencySymbol"]; 53 | } 54 | -(NSString *)organizationId { 55 | return [self string:@"organizationId"]; 56 | } 57 | -(BOOL)organizationIsMultiCurrency { 58 | return [self boolean:@"organizationMultiCurrency"]; 59 | } 60 | -(NSString *)organizationName { 61 | return [self string:@"organizationName"]; 62 | } 63 | -(NSString *)defaultCurrencyIsoCode { 64 | return [self string:@"userDefaultCurrencyIsoCode"]; 65 | } 66 | -(NSString *)email { 67 | return [self string:@"userEmail"]; 68 | } 69 | -(NSString *)fullName { 70 | return [self string:@"userFullName"]; 71 | } 72 | -(NSString *)userId { 73 | return [self string:@"userId"]; 74 | } 75 | -(NSString *)language { 76 | return [self string:@"userLanguage"]; 77 | } 78 | -(NSString *)locale { 79 | return [self string:@"userLocale"]; 80 | } 81 | -(NSString *)timeZone { 82 | return [self string:@"userTimeZone"]; 83 | } 84 | -(NSString *)skin { 85 | return [self string:@"userUiSkin"]; 86 | } 87 | -(NSString *)licenseType { 88 | return [self string:@"licenseType"]; 89 | } 90 | -(NSString *)profileId { 91 | return [self string:@"profileId"]; 92 | } 93 | -(NSString *)roleId { 94 | return [self string:@"roleId"]; 95 | } 96 | -(NSString *)userName { 97 | return [self string:@"userName"]; 98 | } 99 | 100 | @end 101 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/ApexLoader.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ApexLoader.h" 23 | #import "Options.h" 24 | #import "ZKLoginController.h" 25 | #import "Loader.h" 26 | 27 | @interface ApexLoader (Private) 28 | - (void)showLogin:(id)sender; 29 | - (void)doAuthenticatedOperation:(id)sender; 30 | @end 31 | 32 | @implementation ApexLoader 33 | 34 | + (void)initialize { 35 | NSMutableDictionary * defaults = [NSMutableDictionary dictionary]; 36 | NSString *prod = [NSString stringWithString:@"https://www.salesforce.com"]; 37 | NSString *test = [NSString stringWithString:@"https://test.salesforce.com"]; 38 | NSMutableArray * defaultServers = [NSMutableArray arrayWithObjects:prod, test, nil]; 39 | [defaults setObject:defaultServers forKey:@"servers"]; 40 | [defaults setObject:prod forKey:@"server"]; 41 | [[NSUserDefaults standardUserDefaults] registerDefaults:defaults]; 42 | } 43 | 44 | - (void)dealloc { 45 | [login release]; 46 | [options release]; 47 | [super dealloc]; 48 | } 49 | 50 | - (void)finishedLaunching:(id)sender { 51 | options = [[Options alloc] init]; 52 | if (![options parseArguments:[[NSProcessInfo processInfo] arguments]]) { 53 | // show error 54 | return; 55 | } 56 | switch ([options operation]) { 57 | case opPackages: 58 | case opTriggers: 59 | case opApexPages: 60 | case opRunTests: 61 | case opExecAnon: 62 | [self performSelectorOnMainThread:@selector(doAuthenticatedOperation:) withObject:nil waitUntilDone:NO]; 63 | break; 64 | case opSetKeychain: 65 | [self performSelectorOnMainThread:@selector(showLogin:) withObject:nil waitUntilDone:NO]; 66 | } 67 | } 68 | 69 | - (void)awakeFromNib { 70 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(finishedLaunching:) name:NSApplicationDidFinishLaunchingNotification object:nil]; 71 | } 72 | 73 | - (void)loginComplete:(id)sender { 74 | [NSApp terminate:self]; 75 | } 76 | 77 | - (void)initLoginController { 78 | [login release]; 79 | login = [[ZKLoginController alloc] init]; 80 | [login setClientIdFromInfoPlist]; 81 | } 82 | 83 | - (void)showLogin:(id)sender { 84 | [self initLoginController]; 85 | [login showLoginWindow:self target:self selector:@selector(loginComplete:)]; 86 | } 87 | 88 | - (void)performAuthenticatedOperation:(id)sforce { 89 | Loader * loader = [[[Loader alloc] initWithSforce:sforce] autorelease]; 90 | [loader performOperation:options]; 91 | [NSApp terminate:self]; 92 | } 93 | 94 | - (void)doAuthenticatedOperation:(id)sender { 95 | [self initLoginController]; 96 | ZKSoapException *ex = nil; 97 | ZKSforceClient *sforce = [login performLogin:&ex]; 98 | if (ex == nil) { 99 | [self performAuthenticatedOperation:sforce]; 100 | } else { 101 | [login setStatusText:[ex reason]]; 102 | [login showLoginWindow:self target:self selector:@selector(performAuthenticatedOperation:)]; 103 | } 104 | } 105 | 106 | @end 107 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkApexClient.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "zkApexClient.h" 23 | #import "ZKEnvelope.h" 24 | #import "zkCompileResult.h" 25 | #import "zkExecuteAnonResult.h" 26 | #import "zkRunTestResult.h" 27 | 28 | @implementation ZKApexClient 29 | 30 | + (id) fromClient:(ZKSforceClient *)sf { 31 | return [[[ZKApexClient alloc] initFromClient:sf] autorelease]; 32 | } 33 | 34 | - (id) initFromClient:(ZKSforceClient *)sf { 35 | self = [super init]; 36 | sforce = [sf retain]; 37 | return self; 38 | } 39 | 40 | - (void)dealloc { 41 | [sforce release]; 42 | [super dealloc]; 43 | } 44 | 45 | - (void)setEndpointUrl { 46 | [endpointUrl release]; 47 | NSURL *su = [NSURL URLWithString:[sforce serverUrl]]; 48 | endpointUrl = [[NSString stringWithFormat:@"%@://%@/services/Soap/s/22.0", [su scheme], [su host]] copy]; 49 | } 50 | 51 | - (ZKEnvelope *)startEnvelope { 52 | ZKEnvelope *e = [[[ZKEnvelope alloc] init] autorelease]; 53 | [e start:@"http://soap.sforce.com/2006/08/apex"]; 54 | [e writeSessionHeader:[sforce sessionId]]; 55 | [e writeCallOptionsHeader:[sforce clientId]]; 56 | [e moveToBody]; 57 | [self setEndpointUrl]; 58 | return e; 59 | } 60 | 61 | - (NSArray *)sendAndParseResults:(ZKEnvelope *)requestEnv resultType:(Class)resultClass { 62 | NSError * err = NULL; 63 | NSXMLNode * resRoot = [self sendRequest:[requestEnv end]]; 64 | NSArray * results = [resRoot nodesForXPath:@"result" error:&err]; 65 | NSMutableArray *resArr = [NSMutableArray array]; 66 | NSEnumerator * e = [results objectEnumerator]; 67 | NSXMLElement *xmle; 68 | while (xmle = [e nextObject]) { 69 | NSObject *o = [[resultClass alloc] initWithXmlElement:xmle]; 70 | [resArr addObject:o]; 71 | [o release]; 72 | } 73 | return resArr; 74 | } 75 | 76 | - (NSArray *)compile:(NSString *)elemName src:(NSArray *)src { 77 | ZKEnvelope * env = [self startEnvelope]; 78 | [env startElement:elemName]; 79 | [env addElementArray:@"scripts" elemValue:src]; 80 | [env endElement:elemName]; 81 | [env endElement:@"s:Body"]; 82 | return [self sendAndParseResults:env resultType:[ZKCompileResult class]]; 83 | } 84 | 85 | - (NSArray *)compilePackages:(NSArray *)src { 86 | return [self compile:@"compilePackages" src:src]; 87 | } 88 | 89 | - (NSArray *)compileTriggers:(NSArray *)src { 90 | return [self compile:@"compileTriggers" src:src]; 91 | } 92 | 93 | - (ZKExecuteAnonymousResult *)executeAnonymous:(NSString *)src { 94 | ZKEnvelope * env = [self startEnvelope]; 95 | [env startElement:@"executeAnonymous"]; 96 | [env addElement:@"String" elemValue:src]; 97 | [env endElement:@"executeAnonymous"]; 98 | [env endElement:@"s:Body"]; 99 | return [[self sendAndParseResults:env resultType:[ZKExecuteAnonymousResult class]] objectAtIndex:0]; 100 | } 101 | 102 | - (ZKRunTestResult *)runTests:(BOOL)allTests namespace:(NSString *)ns packages:(NSArray *)pkgs { 103 | ZKEnvelope *env = [self startEnvelope]; 104 | [env startElement:@"runTests"]; 105 | [env startElement:@"RunTestsRequest"]; 106 | [env addElement:@"allTests" elemValue:allTests ? @"true" : @"false"]; 107 | [env addElement:@"namespace" elemValue:ns]; 108 | [env addElement:@"packages" elemValue:pkgs]; 109 | [env endElement:@"RunTestsRequest"]; 110 | [env endElement:@"runTests"]; 111 | [env endElement:@"s:Body"]; 112 | return [[self sendAndParseResults:env resultType:[ZKRunTestResult class]] objectAtIndex:0]; 113 | } 114 | 115 | @end 116 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkDescribeField.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import 24 | #import "zkXmlDeserializer.h" 25 | 26 | /* 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | */ 64 | 65 | @class ZKDescribeSObject; 66 | 67 | @interface ZKDescribeField : ZKXmlDeserializer { 68 | NSArray *picklistValues; 69 | ZKDescribeSObject *sobject; 70 | } 71 | - (void)setSobject:(ZKDescribeSObject *)s; 72 | - (ZKDescribeSObject *)sobject; 73 | 74 | // Api v7.0 75 | - (BOOL)autoNumber; 76 | - (int)byteLength; 77 | - (BOOL)calculated; 78 | - (NSString *)controllerName; 79 | - (BOOL)createable; 80 | - (BOOL)custom; 81 | - (BOOL)defaultOnCreate; 82 | - (BOOL)dependentPicklist; 83 | - (int)digits; 84 | - (BOOL)externalId; 85 | - (BOOL)filterable; 86 | - (BOOL)htmlFormatted; 87 | - (NSString *)label; 88 | - (int)length; 89 | - (NSString *)name; 90 | - (BOOL)nameField; 91 | - (BOOL)nillable; 92 | - (NSArray *)picklistValues; 93 | - (int)precision; 94 | - (NSArray *)referenceTo; 95 | - (NSString *)relationshipName; 96 | - (BOOL)restrictedPicklist; 97 | - (int)scale; 98 | - (NSString *)soapType; 99 | - (NSString *)type; 100 | - (BOOL)updateable; 101 | // Api v8.0 102 | - (NSString *)calculatedFormula; 103 | - (BOOL)caseSensitive; 104 | - (NSString *)defaultValueFormula; 105 | - (BOOL)namePointing; 106 | - (BOOL)sortable; 107 | - (BOOL)unique; 108 | // Api v11.1 109 | - (BOOL)idLookup; 110 | // Api v13.0 111 | - (int)relationshipOrder; // for CJO's, is this the first or 2nd FK to the parent ? 112 | - (BOOL)writeRequiresMasterRead; // writing to this requires at least read access to the parent object (e.g. on CJO's) 113 | // Api v14.0 114 | - (NSString *)inlineHelpText; 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkEnvelope.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkEnvelope.h" 24 | 25 | @implementation ZKEnvelope 26 | 27 | enum envState { 28 | inEnvelope = 1, 29 | inHeaders = 2, 30 | inBody = 3 31 | }; 32 | 33 | - (void)start:(NSString *)primaryNamespceUri { 34 | [env release]; 35 | env = [NSMutableString stringWithFormat:@"", primaryNamespceUri]; 36 | state = inEnvelope; 37 | } 38 | 39 | - (void)moveToHeaders { 40 | if (state == inBody) 41 | @throw [NSException exceptionWithName:@"Illegal State Exception" reason:@"Unable to write headers once we've moved to the body" userInfo:nil]; 42 | if (state == inHeaders) return; 43 | [self startElement:@"s:Header"]; 44 | state = inHeaders; 45 | } 46 | 47 | - (void)writeSessionHeader:(NSString *)sessionId { 48 | if ([sessionId length] == 0) return; 49 | [self moveToHeaders]; 50 | [self startElement:@"SessionHeader"]; 51 | [self addElement:@"sessionId" elemValue:sessionId]; 52 | [self endElement:@"SessionHeader"]; 53 | } 54 | 55 | - (void)writeCallOptionsHeader:(NSString *)clientId { 56 | if ([clientId length] == 0) return; 57 | [self moveToHeaders]; 58 | [self startElement:@"CallOptions"]; 59 | [self addElement:@"client" elemValue:clientId]; 60 | [self endElement:@"CallOptions"]; 61 | } 62 | 63 | - (void)writeMruHeader:(BOOL)updateMru { 64 | if (!updateMru) return; 65 | [self moveToHeaders]; 66 | [self startElement:@"MruHeader"]; 67 | [self addElement:@"updateMru" elemValue:@"true"]; 68 | [self endElement:@"MruHeader"]; 69 | } 70 | 71 | - (void) moveToBody { 72 | if (state == inHeaders) 73 | [self endElement:@"s:Header"]; 74 | if (state != inBody) 75 | [self startElement:@"s:Body"]; 76 | state = inBody; 77 | } 78 | 79 | - (void) addElement:(NSString *)elemName elemValue:(id)elemValue { 80 | if ([elemValue isKindOfClass:[NSString class]]) [self addElementString:elemName elemValue:elemValue]; 81 | else if ([elemValue isKindOfClass:[NSArray class]]) [self addElementArray:elemName elemValue:elemValue]; 82 | else if ([elemValue isKindOfClass:[ZKSObject class]]) [self addElementSObject:elemName elemValue:elemValue]; 83 | else [self addElementString:elemName elemValue:[elemValue stringValue]]; 84 | } 85 | 86 | - (void) addElementArray:(NSString *)elemName elemValue:(NSArray *)elemValues { 87 | NSEnumerator *e = [elemValues objectEnumerator]; 88 | id o; 89 | while(o = [e nextObject]) 90 | [self addElement:elemName elemValue:o]; 91 | } 92 | 93 | - (void) addElementString:(NSString *)elemName elemValue:(NSString *)elemValue { 94 | [self startElement:elemName]; 95 | [self writeText:elemValue]; 96 | [self endElement:elemName]; 97 | } 98 | 99 | - (void) addElementSObject:(NSString *)elemName elemValue:(ZKSObject *)sobject { 100 | [self startElement:elemName]; 101 | [self addElement:@"type" elemValue:[sobject type]]; 102 | [self addElement:@"fieldsToNull" elemValue:[sobject fieldsToNull]]; 103 | if ([sobject id]) 104 | [self addElement:@"Id" elemValue:[sobject id]]; 105 | NSEnumerator *e = [[sobject fields] keyEnumerator]; 106 | NSString *key; 107 | while(key = [e nextObject]) { 108 | [self addElement:key elemValue:[[sobject fields] valueForKey:key]]; 109 | } 110 | [self endElement:elemName]; 111 | } 112 | 113 | - (void) writeText:(NSString *)text { 114 | unichar c; 115 | unsigned int i, len = [text length]; 116 | for(i = 0; i < len; i++) 117 | { 118 | c = [text characterAtIndex:i]; 119 | switch (c) 120 | { 121 | case '<' : [env appendString:@"<"]; break; 122 | case '>' : [env appendString:@">"]; break; 123 | case '&' : [env appendString:@"&"]; break; 124 | default : [env appendFormat:@"%C", c]; 125 | } 126 | } 127 | } 128 | 129 | - (void )startElement:(NSString *)elemName { 130 | [env appendFormat:@"<%@>", elemName]; 131 | } 132 | 133 | - (void )endElement:(NSString *)elemName { 134 | [env appendFormat:@"", elemName]; 135 | } 136 | 137 | - (NSString *)end { 138 | [env appendString:@""]; 139 | return env; 140 | } 141 | 142 | @end 143 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkDescribeSObject.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2007 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkDescribeSObject.h" 24 | #import "zkDescribeField.h" 25 | #import "zkChildRelationship.h" 26 | #import "zkRecordTypeInfo.h" 27 | 28 | @implementation ZKDescribeSObject 29 | 30 | -(void)dealloc { 31 | [fields release]; 32 | [fieldsByName release]; 33 | [childRelationships release]; 34 | [recordTypeInfos release]; 35 | [super dealloc]; 36 | } 37 | 38 | -(BOOL)activateable { 39 | return [self boolean:@"activateable"]; 40 | } 41 | -(BOOL)createable { 42 | return [self boolean:@"createable"]; 43 | } 44 | -(BOOL)custom { 45 | return [self boolean:@"custom"]; 46 | } 47 | -(BOOL)deletable { 48 | return [self boolean:@"deletable"]; 49 | } 50 | -(BOOL)layoutable { 51 | return [self boolean:@"layoutable"]; 52 | } 53 | -(BOOL)mergeable { 54 | return [self boolean:@"mergeable"]; 55 | } 56 | -(BOOL)queryable { 57 | return [self boolean:@"queryable"]; 58 | } 59 | -(BOOL)replicateable { 60 | return [self boolean:@"replicateable"]; 61 | } 62 | -(BOOL)retrieveable { 63 | return [self boolean:@"retrieveable"]; 64 | } 65 | -(BOOL)searchable { 66 | return [self boolean:@"searchable"]; 67 | } 68 | -(BOOL)triggerable { 69 | return [self boolean:@"triggerable"]; 70 | } 71 | -(BOOL)undeleteable { 72 | return [self boolean:@"undeleteable"]; 73 | } 74 | -(BOOL)updateable { 75 | return [self boolean:@"updateable"]; 76 | } 77 | -(NSString *)keyPrefix { 78 | return [self string:@"keyPrefix"]; 79 | } 80 | -(NSString *)label { 81 | return [self string:@"label"]; 82 | } 83 | -(NSString *)labelPlural { 84 | return [self string:@"labelPlural"]; 85 | } 86 | -(NSString *)name { 87 | return [self string:@"name"]; 88 | } 89 | -(NSString *)urlDetail { 90 | return [self string:@"urlDetail"]; 91 | } 92 | -(NSString *)urlEdit { 93 | return [self string:@"urlEdit"]; 94 | } 95 | -(NSString *)urlNew { 96 | return [self string:@"urlNew"]; 97 | } 98 | 99 | -(NSArray *)fields { 100 | if (fields == nil) { 101 | NSArray * fn = [node elementsForName:@"fields"]; 102 | NSMutableDictionary *byName = [NSMutableDictionary dictionary]; 103 | NSMutableArray * fs = [NSMutableArray arrayWithCapacity:[fn count]]; 104 | NSXMLNode * fieldNode; 105 | NSEnumerator *e = [fn objectEnumerator]; 106 | while (fieldNode = [e nextObject]) { 107 | ZKDescribeField * df = [[ZKDescribeField alloc] initWithXmlElement:(NSXMLElement*)fieldNode]; 108 | [df setSobject:self]; 109 | [fs addObject:df]; 110 | [byName setObject:df forKey:[[df name] lowercaseString]]; 111 | [df release]; 112 | } 113 | fields = [fs retain]; 114 | fieldsByName = [byName retain]; 115 | } 116 | return fields; 117 | } 118 | 119 | -(ZKDescribeField *)fieldWithName:(NSString *)name { 120 | if (fieldsByName == nil) 121 | [self fields]; 122 | return [fieldsByName objectForKey:[name lowercaseString]]; 123 | } 124 | 125 | -(NSArray *)childRelationships { 126 | if (childRelationships == nil) { 127 | NSArray *crn = [node elementsForName:@"childRelationships"]; 128 | NSMutableArray *crs = [NSMutableArray arrayWithCapacity:[crn count]]; 129 | NSXMLNode * crNode; 130 | NSEnumerator *e = [crn objectEnumerator]; 131 | while (crNode = [e nextObject]) { 132 | ZKChildRelationship * cr = [[ZKChildRelationship alloc] initWithXmlElement:(NSXMLElement*)crNode]; 133 | [crs addObject:cr]; 134 | [cr release]; 135 | } 136 | childRelationships = [crs retain]; 137 | } 138 | return childRelationships; 139 | } 140 | 141 | - (NSString *)description { 142 | return [NSString stringWithFormat:@"SObject %@ (%@)", [self name], [self label]]; 143 | } 144 | 145 | -(NSArray *)recordTypeInfos { 146 | if (recordTypeInfos == nil) { 147 | NSArray *rti = [node elementsForName:@"recordTypeInfos"]; 148 | NSMutableArray *res = [NSMutableArray arrayWithCapacity:[rti count]]; 149 | NSXMLNode *rnode; 150 | NSEnumerator *e = [rti objectEnumerator]; 151 | while (rnode = [e nextObject]) { 152 | ZKRecordTypeInfo *r = [[ZKRecordTypeInfo alloc] initWithXmlElement:(NSXMLElement*)rnode]; 153 | [res addObject:r]; 154 | [r release]; 155 | } 156 | recordTypeInfos = [res retain]; 157 | } 158 | return recordTypeInfos; 159 | } 160 | 161 | @end 162 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkDescribeField.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkDescribeField.h" 24 | #import "zkPicklistEntry.h" 25 | 26 | @implementation ZKDescribeField 27 | 28 | - (void)dealloc { 29 | [picklistValues release]; 30 | [super dealloc]; 31 | } 32 | 33 | - (id)copyWithZone:(NSZone *)zone { 34 | NSXMLElement *n = [[node copyWithZone:zone] autorelease]; 35 | ZKDescribeField *rhs = [[ZKDescribeField alloc] initWithXmlElement:n]; 36 | [rhs setSobject:sobject]; 37 | return rhs; 38 | } 39 | - (NSXMLElement *)node { 40 | return node; 41 | } 42 | - (BOOL)isEqual:(id)anObject { 43 | if (![anObject isKindOfClass:[ZKDescribeField class]]) return NO; 44 | return [node isEqual:[anObject node]]; 45 | } 46 | - (void)setSobject:(ZKDescribeSObject *)s { 47 | // note we explicitly don't retain this to stop a retain cycle between us and the parent sobject. 48 | // as it has a reatined reference on us, it can't go away before we do. 49 | sobject = s; 50 | } 51 | - (ZKDescribeSObject *)sobject { 52 | return sobject; 53 | } 54 | 55 | - (unsigned)hash { 56 | return [node hash]; 57 | } 58 | - (BOOL)autoNumber { 59 | return [self boolean:@"autoNumber"]; 60 | } 61 | - (int)byteLength { 62 | return [self integer:@"byteLength"]; 63 | } 64 | - (BOOL)calculated { 65 | return [self boolean:@"calculated"]; 66 | } 67 | - (NSString *)controllerName { 68 | return [self string:@"controllerName"]; 69 | } 70 | - (BOOL)createable { 71 | return [self boolean:@"createable"]; 72 | } 73 | - (BOOL)custom { 74 | return [self boolean:@"custom"]; 75 | } 76 | - (BOOL)defaultOnCreate { 77 | return [self boolean:@"defaultOnCreate"]; 78 | } 79 | - (BOOL)dependentPicklist { 80 | return [self boolean:@"dependentPicklist"]; 81 | } 82 | - (int)digits { 83 | return [self integer:@"digits"]; 84 | } 85 | - (BOOL)externalId { 86 | return [self boolean:@"externalId"]; 87 | } 88 | - (BOOL)filterable { 89 | return [self boolean:@"filterable"]; 90 | } 91 | - (BOOL)htmlFormatted { 92 | return [self boolean:@"htmlFormatted"]; 93 | } 94 | - (NSString *)label { 95 | return [self string:@"label"]; 96 | } 97 | - (int)length { 98 | return [self integer:@"length"]; 99 | } 100 | - (NSString *)name { 101 | return [self string:@"name"]; 102 | } 103 | - (BOOL)nameField { 104 | return [self boolean:@"nameField"]; 105 | } 106 | - (BOOL)nillable { 107 | return [self boolean:@"nillable"]; 108 | } 109 | - (NSArray *)picklistValues { 110 | if (picklistValues == nil) { 111 | NSArray *plv = [node elementsForName:@"picklistValues"]; 112 | NSMutableArray *res = [NSMutableArray arrayWithCapacity:[plv count]]; 113 | NSXMLNode * plNode; 114 | NSEnumerator *e = [plv objectEnumerator]; 115 | while (plNode = [e nextObject]) { 116 | ZKPicklistEntry *ple = [[ZKPicklistEntry alloc] initWithXmlElement:(NSXMLElement*)plNode]; 117 | [res addObject:ple]; 118 | [ple release]; 119 | } 120 | picklistValues = [res retain]; 121 | } 122 | return picklistValues; 123 | } 124 | - (int)precision { 125 | return [self integer:@"precision"]; 126 | } 127 | - (NSArray *)referenceTo { 128 | return [self strings:@"referenceTo"]; 129 | } 130 | - (NSString *)relationshipName { 131 | return [self string:@"relationshipName"]; 132 | } 133 | - (BOOL)restrictedPicklist { 134 | return [self boolean:@"restrictedPicklist"]; 135 | } 136 | - (int)scale { 137 | return [self integer:@"scale"]; 138 | } 139 | - (NSString *)soapType { 140 | return [self string:@"soapType"]; 141 | } 142 | - (NSString *)type { 143 | return [self string:@"type"]; 144 | } 145 | - (BOOL)updateable { 146 | return [self boolean:@"updateable"]; 147 | } 148 | - (NSString *)description { 149 | return [NSString stringWithFormat:@"Field %@ (%@)", [self name], [self label]]; 150 | } 151 | - (NSString *)calculatedFormula { 152 | return [self string:@"calculatedFormula"]; 153 | } 154 | - (BOOL)caseSensitive { 155 | return [self boolean:@"caseSensitive"]; 156 | } 157 | - (NSString *)defaultValueFormula { 158 | return [self string:@"defaultValueFormula"]; 159 | } 160 | - (BOOL)namePointing { 161 | return [self boolean:@"namePointing"]; 162 | } 163 | - (BOOL)sortable { 164 | return [self boolean:@"sortable"]; 165 | } 166 | - (BOOL)unique { 167 | return [self boolean:@"unique"]; 168 | } 169 | - (BOOL)idLookup { 170 | return [self boolean:@"idLookup"]; 171 | } 172 | - (int)relationshipOrder { 173 | return [self integer:@"relationshipOrder"]; 174 | } 175 | - (BOOL)writeRequiresMasterRead { 176 | return [self boolean:@"writeRequiresMasterRead"]; 177 | } 178 | - (NSString *)inlineHelpText { 179 | return [self string:@"inlineHelpText"]; 180 | } 181 | 182 | @end 183 | -------------------------------------------------------------------------------- /plugin/Syntaxes/Apex.tmLanguage: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | fileTypes 6 | 7 | apex 8 | 9 | foldingStartMarker 10 | /\*\*|\{\s*$ 11 | foldingStopMarker 12 | \*\*/|^\s*\} 13 | name 14 | Apex 15 | patterns 16 | 17 | 18 | match 19 | \b(?i:package|trigger|class|interface)\b 20 | name 21 | storage.type.apex 22 | 23 | 24 | match 25 | \b(?i:webservice|testmethod)\b 26 | name 27 | keyword.control.annotation.apex 28 | 29 | 30 | match 31 | \b(?i:commit|rollback)\b 32 | name 33 | keyword.control.transaction.apex 34 | 35 | 36 | match 37 | \b(?i:insert|update|delete)\b 38 | name 39 | keyword.control.dml.apex 40 | 41 | 42 | match 43 | \b(?i:webservice|testmethod)\b 44 | name 45 | keyword.control.annotation.apex 46 | 47 | 48 | match 49 | \b(?i:try|catch|finally|throw)\b 50 | name 51 | keyword.control.catch-exception.apex 52 | 53 | 54 | match 55 | \b(?i:return|break|case|continue|default|do|while|for|switch|if|else)\b 56 | name 57 | keyword.control.apex 58 | 59 | 60 | include 61 | #strings 62 | 63 | 64 | include 65 | #comments 66 | 67 | 68 | include 69 | #support-type-built-ins-apex 70 | 71 | 72 | begin 73 | \[ 74 | beginCaptures 75 | 76 | 0 77 | 78 | name 79 | punctuation.definition.soql.begin.apex 80 | 81 | 82 | end 83 | \] 84 | endCaptures 85 | 86 | 0 87 | 88 | name 89 | punctuation.definition.soql.end.apex 90 | 91 | 92 | name 93 | string.quoted.brackets.soql.apex 94 | 95 | 96 | repository 97 | 98 | comments 99 | 100 | patterns 101 | 102 | 103 | name 104 | comment.block.empty.apex 105 | match 106 | /\*\*/ 107 | captures 108 | 109 | 0 110 | 111 | name 112 | punctuation.definition.comment.apex 113 | 114 | 115 | 116 | 117 | include 118 | #comments-inline 119 | 120 | 121 | 122 | comments-inline 123 | 124 | patterns 125 | 126 | 127 | name 128 | comment.block.apex 129 | begin 130 | /\* 131 | end 132 | \*/ 133 | captures 134 | 135 | 0 136 | 137 | name 138 | punctuation.definition.comment.apex 139 | 140 | 141 | 142 | 143 | match 144 | \s*((//).*$\n?) 145 | captures 146 | 147 | 1 148 | 149 | name 150 | comment.line.double-slash.apex 151 | 152 | 2 153 | 154 | name 155 | punctuation.definition.comment.apex 156 | 157 | 158 | 159 | 160 | 161 | strings 162 | 163 | patterns 164 | 165 | 166 | begin 167 | ' 168 | beginCaptures 169 | 170 | 0 171 | 172 | name 173 | punctuation.definition.string.begin.apex 174 | 175 | 176 | end 177 | ' 178 | endCaptures 179 | 180 | 0 181 | 182 | name 183 | punctuation.definition.string.end.apex 184 | 185 | 186 | name 187 | string.quoted.single.apex 188 | patterns 189 | 190 | 191 | match 192 | \\. 193 | name 194 | constant.character.escape.apex 195 | 196 | 197 | 198 | 199 | 200 | support-type-built-ins-apex 201 | 202 | match 203 | \b(?i:integer|string|void|double|boolean|date|datetime|id)\b 204 | name 205 | support.type.built-ins.apex 206 | 207 | 208 | scopeName 209 | source.apex 210 | uuid 211 | C4D3A5F4-B1DE-48C5-84CE-AC99DDA78292 212 | 213 | 214 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSObject.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkSObject.h" 24 | #import "zkQueryResult.h" 25 | 26 | NSString * NS_URI_XSI = @"http://www.w3.org/2001/XMLSchema-instance"; 27 | 28 | @implementation ZKSObject 29 | 30 | + (id)withType:(NSString *)type { 31 | return [[[ZKSObject alloc] initWithType:type] autorelease]; 32 | } 33 | 34 | + (id)withTypeAndId:(NSString *)type sfId:(NSString *)sfId { 35 | ZKSObject *s = [ZKSObject withType:type]; 36 | [s setId:sfId]; 37 | return s; 38 | } 39 | 40 | + (id) fromXmlNode:(NSXMLNode *)node { 41 | return [[[ZKSObject alloc] initFromXmlNode:node] autorelease]; 42 | } 43 | 44 | - (id) initWithType:(NSString *)aType { 45 | self = [super init]; 46 | type = [aType retain]; 47 | fieldsToNull = [[NSMutableSet alloc] init]; 48 | fields = [[NSMutableDictionary alloc] init]; 49 | return self; 50 | } 51 | 52 | - (id) initFromXmlNode:(NSXMLNode *)node { 53 | self = [super init]; 54 | NSError *err = NULL; 55 | int i, childCount; 56 | Id = [[[[node nodesForXPath:@"sf:Id" error:&err] objectAtIndex:0] stringValue] copy]; 57 | type = [[[[node nodesForXPath:@"sf:type" error:&err] objectAtIndex:0] stringValue] copy]; 58 | fields = [[NSMutableDictionary alloc] init]; 59 | fieldsToNull = [[NSMutableSet alloc] init]; 60 | NSArray *children = [node children]; 61 | childCount = [children count]; 62 | // start at 2 to skip Id & Type 63 | for (i = 2; i < childCount; i++) 64 | { 65 | NSXMLElement *f = [children objectAtIndex:i]; 66 | if ([f kind] != NSXMLElementKind) continue; 67 | NSXMLNode *xsiNil = [f attributeForLocalName:@"nil" URI:NS_URI_XSI]; 68 | id fieldVal; 69 | if (xsiNil != nil && [[xsiNil stringValue] isEqualToString:@"true"]) 70 | fieldVal = [NSNull null]; 71 | else { 72 | NSXMLNode *xsiType = [f attributeForLocalName:@"type" URI:NS_URI_XSI]; 73 | if (xsiType == nil) 74 | fieldVal = [f stringValue]; 75 | else if ([[xsiType stringValue] hasSuffix:@"QueryResult"]) 76 | fieldVal = [[[ZKQueryResult alloc] initFromXmlNode:f] autorelease]; 77 | else if ([[xsiType stringValue] hasSuffix:@"sObject"]) 78 | fieldVal = [[[ZKSObject alloc] initFromXmlNode:f] autorelease]; 79 | else 80 | NSLog(@"xsiType is %@", xsiType); 81 | } 82 | [fields setObject:fieldVal forKey:[f localName]]; 83 | } 84 | return self; 85 | } 86 | 87 | -(id)initWithId:(NSString *)anId type:(NSString *)t fieldsToNull:(NSSet *)ftn fields:(NSDictionary *)f { 88 | self = [super init]; 89 | Id = [anId copy]; 90 | type = [t copy]; 91 | fieldsToNull = [[NSMutableSet setWithSet:ftn] retain]; 92 | fields = [[NSMutableDictionary dictionaryWithDictionary:f] retain]; 93 | return self; 94 | } 95 | 96 | -(id)copyWithZone:(NSZone *)zone { 97 | return [[ZKSObject alloc] initWithId:Id type:type fieldsToNull:fieldsToNull fields:fields]; 98 | } 99 | 100 | 101 | - (void)dealloc { 102 | [Id release]; 103 | [type release]; 104 | [fieldsToNull release]; 105 | [fields release]; 106 | [super dealloc]; 107 | } 108 | 109 | - (id)description { 110 | return [NSString stringWithFormat:@"%@ %@ fields=%@ toNull=%@", type, Id, fields, fieldsToNull]; 111 | } 112 | 113 | - (void)setId:(NSString *)theId { 114 | if (Id == theId) return; 115 | [Id release]; 116 | Id = [theId retain]; 117 | } 118 | 119 | - (void)setFieldToNull:(NSString *)field { 120 | [fieldsToNull addObject:field]; 121 | [fields removeObjectForKey:field]; 122 | } 123 | 124 | - (void)setFieldValue:(NSString *)value field:(NSString *)field { 125 | if((value == nil) || ([value length] == 0)) { 126 | [self setFieldToNull:field]; 127 | } else { 128 | [fields setObject:value forKey:field]; 129 | [fieldsToNull removeObject:field]; 130 | } 131 | } 132 | 133 | - (void)setFieldDateTimeValue:(NSCalendarDate *)value field:(NSString *)field { 134 | NSMutableString *dt = [NSMutableString stringWithString:[value descriptionWithCalendarFormat:@"%Y-%m-%dT%H:%M:%S.%F%z"]]; 135 | // insert the : in the TZ offset, to make it xsd:dateTime 136 | [dt insertString:@":" atIndex:[dt length]-2]; 137 | [self setFieldValue:dt field:field]; 138 | } 139 | 140 | - (void)setFieldDateValue:(NSCalendarDate *)value field:(NSString *)field { 141 | [self setFieldValue:[value descriptionWithCalendarFormat:@"%Y-%m-%d"] field:field]; 142 | } 143 | 144 | - (id)fieldValue:(NSString *)field { 145 | id v = [fields objectForKey:field]; 146 | return v == [NSNull null] ? nil : v; 147 | } 148 | 149 | - (BOOL)isFieldToNull:(NSString *)field { 150 | return [fieldsToNull containsObject:field]; 151 | } 152 | 153 | - (BOOL)boolValue:(NSString *)field { 154 | return [[self fieldValue:field] isEqualToString:@"true"]; 155 | } 156 | 157 | - (NSCalendarDate *)dateTimeValue:(NSString *)field { 158 | // ok, so a little hackish, but does the job 159 | // note to self, make sure API always returns GMT times ;) 160 | NSCalendarDate * d = [NSCalendarDate dateWithString:[[self fieldValue:field] stringByAppendingString:@" GMT"] calendarFormat:@"%Y-%m-%dT%H:%M:%S.%FZ %Z"]; 161 | return d; 162 | } 163 | 164 | - (NSCalendarDate *)dateValue:(NSString *)field { 165 | return [NSCalendarDate dateWithString:[self fieldValue:field] calendarFormat:@"%Y-%m-%d"]; 166 | } 167 | 168 | - (int)intValue:(NSString *)field { 169 | return [[self fieldValue:field] intValue]; 170 | } 171 | 172 | - (double)doubleValue:(NSString *)field { 173 | return [[self fieldValue:field] doubleValue]; 174 | } 175 | 176 | - (ZKQueryResult *)queryResultValue:(NSString *)field { 177 | return [self fieldValue:field]; 178 | } 179 | 180 | - (NSString *)id { 181 | return Id; 182 | } 183 | 184 | - (NSString *)type { 185 | return type; 186 | } 187 | 188 | - (NSArray *)fieldsToNull { 189 | return [fieldsToNull allObjects]; 190 | } 191 | 192 | - (NSDictionary *)fields { 193 | return fields; 194 | } 195 | 196 | @end 197 | -------------------------------------------------------------------------------- /apexLoader/apexLoader/Loader.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2007-2008,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "Loader.h" 23 | #import "Options.h" 24 | #import "zkSforceClient.h" 25 | #import "ZKCompileResult.h" 26 | #import "zkApexClient.h" 27 | #import "zkExecuteAnonResult.h" 28 | #import "zkRunTestResult.h" 29 | #import "zkRunTestFailure.h" 30 | #import "zkSObject.h" 31 | #import "zkSaveResult.h" 32 | 33 | @implementation Loader 34 | 35 | - (id)initWithSforce:(ZKSforceClient *)sf { 36 | self = [super init]; 37 | sforce = [sf retain]; 38 | apex = [[ZKApexClient fromClient:sf] retain]; 39 | return self; 40 | } 41 | 42 | - (void)dealloc { 43 | [sforce release]; 44 | [apex release]; 45 | [super dealloc]; 46 | } 47 | 48 | - (void)logHtml:(NSString *)fmt withLevel:(LogLevel)lvl { 49 | NSString *div = lvl == logError ? @" class='err'" : @""; 50 | printf("%s\n", [div UTF8String], [fmt UTF8String]); 51 | } 52 | 53 | - (NSString *)operationDescription { 54 | switch (operation) { 55 | case opPackages: return @"Compiling Apex Class"; 56 | case opTriggers: return @"Compiling Apex Trigger"; 57 | case opApexPages: return @"Deploying Apex Page"; 58 | case opExecAnon: return @"Execute Anonymous"; 59 | case opRunTests: return @"Running Apex Unit Tests"; 60 | case opSetKeychain: return @"Saving Credentials"; 61 | } 62 | return @""; 63 | } 64 | 65 | 66 | - (void)initOutput { 67 | printf(""); 72 | printf("

%s

", [[self operationDescription] UTF8String]); 73 | } 74 | 75 | - (void)finalizeOutput { 76 | printf("
"); 77 | } 78 | 79 | - (void)log:(LogLevel)level msg:(NSString *)fmt { 80 | [self logHtml:fmt withLevel:level]; 81 | } 82 | 83 | - (NSString *)textMateUrlforLine:(int)ln column:(int)col { 84 | return [NSString stringWithFormat:@"txmt://open?line=%d&column=%d", ln, col]; 85 | } 86 | 87 | - (void)logCompileError:(NSString *)problem line:(int)ln column:(int)col { 88 | NSString *txtMateUrl = [self textMateUrlforLine:ln column:col]; 89 | [self log:logError msg:[NSString stringWithFormat:@"Compile Error: %@ at line %d col %d", txtMateUrl, problem, ln, col]]; 90 | } 91 | 92 | - (void)logCompileError:(ZKCompileResult *)r { 93 | [self logCompileError:[r problem] line:[r line] column:[r column]]; 94 | } 95 | 96 | - (NSArray *)loadFile:(NSString *)file { 97 | NSMutableArray *res = [NSMutableArray array]; 98 | NSError *err = nil; 99 | NSString *c = [NSString stringWithContentsOfFile:file encoding:NSUTF8StringEncoding error:&err]; 100 | if (err != nil) 101 | [self log:logError msg:[NSString stringWithFormat:@"%@ : %@", file, [err localizedDescription]]]; 102 | if (c != nil) 103 | [res addObject:c]; 104 | return res; 105 | } 106 | 107 | - (int)load:(NSString *)file isTrigger:(BOOL)isTrigger { 108 | [self log:logVerbose msg:[NSString stringWithFormat:@"About to load %@ %@", isTrigger ? @"Trigger" : @"Class", file]]; 109 | 110 | NSArray *src = [self loadFile:file]; 111 | NSArray *results = isTrigger ? [apex compileTriggers:src] : [apex compilePackages:src]; 112 | 113 | ZKCompileResult *r; 114 | NSEnumerator *e = [results objectEnumerator]; 115 | int errCount = 0; 116 | while (r = [e nextObject]) { 117 | if ([r success]) 118 | [self log:logVerbose msg:[NSString stringWithFormat:@"Success! (Id is %@ CRC is %x)", [r id], [r bodyCrc]]]; 119 | else { 120 | [self logCompileError:r]; 121 | ++errCount; 122 | } 123 | } 124 | return -errCount; 125 | } 126 | 127 | - (int)runTests:(NSString *)filename { 128 | [self log:logVerbose msg:[NSString stringWithFormat:@"About to run tests from %@", filename]]; 129 | ZKRunTestResult *res = [apex runTests:NO namespace:@"" packages:[NSArray arrayWithObject:filename]]; 130 | if ([res numFailures] > 0) { 131 | [self log:logError msg:[NSString stringWithFormat:@"Failed: %d of %d tests failed", [res numFailures], [res numTestsRun]]]; 132 | int c = 1; 133 | NSEnumerator *e = [[res failures] objectEnumerator]; 134 | ZKRunTestFailure *f; 135 | while ( f = [e nextObject]) { 136 | [self log:logError msg:[NSString stringWithFormat:@"%d. %@.%@ - %@", c++, [f packageName], [f methodName], [f message]]]; 137 | } 138 | } else { 139 | [self log:logVerbose msg:[NSString stringWithFormat:@"Success: %d of %d tests failed", [res numFailures], [res numTestsRun]]]; 140 | } 141 | return -[res numFailures]; 142 | } 143 | 144 | - (int)execAnon:(NSString *)filename { 145 | [self log:logVerbose msg:[NSString stringWithFormat:@"About to execute script %@", filename]]; 146 | NSArray *src = [self loadFile:filename]; 147 | NSString *apexSrc; 148 | NSEnumerator *e = [src objectEnumerator]; 149 | int errCount = 0; 150 | while (apexSrc = [e nextObject]) { 151 | ZKExecuteAnonymousResult *r = [apex executeAnonymous:apexSrc]; 152 | ++errCount; 153 | if (![r compiled]) 154 | [self logCompileError:[r compileProblem] line:[r line] column:[r column]]; 155 | else if (![r success]) { 156 | [self log:logError msg:[NSString stringWithFormat:@"Exception %@\n%@", [r exceptionMessage], [r exceptionStackTrace]]]; 157 | } else { 158 | --errCount; 159 | } 160 | } 161 | return -errCount; 162 | } 163 | 164 | -(int)loadPage:(NSString *)filename { 165 | [self log:logVerbose msg:[NSString stringWithFormat:@"About to deploy apex page: %@", filename]]; 166 | NSArray *src = [self loadFile:filename]; 167 | int errCount = 0; 168 | for (NSString *psrc in src) { 169 | ZKSObject *page = [[[ZKSObject alloc] initWithType:@"ApexPage"] autorelease]; 170 | [page setFieldValue:psrc field:@"Markup"]; 171 | NSString *name = [[filename lastPathComponent] stringByDeletingPathExtension]; 172 | [page setFieldValue:name field:@"Name"]; 173 | [page setFieldValue:name field:@"MasterLabel"]; 174 | ZKSaveResult *sr = [[sforce upsert:@"Name" objects:[NSArray arrayWithObject:page]] objectAtIndex:0]; 175 | if (![sr success]) { 176 | [self log:logError msg:[NSString stringWithFormat:@"%@ : %@", [sr statusCode], [sr message]]]; 177 | errCount++; 178 | } else { 179 | [self log:logVerbose msg:[NSString stringWithFormat:@"Success! ApexPage upserted with Id %@", [sr id]]]; 180 | } 181 | } 182 | return -errCount; 183 | } 184 | 185 | - (int) performOperation:(Options *)op { 186 | operation = [op operation]; 187 | [self initOutput]; 188 | @try { 189 | switch ([op operation]) { 190 | case opPackages: 191 | return [self load:[op filename] isTrigger:NO]; 192 | case opTriggers: 193 | return [self load:[op filename] isTrigger:YES]; 194 | case opApexPages: 195 | return [self loadPage:[op filename]]; 196 | case opExecAnon: 197 | return [self execAnon:[op filename]]; 198 | case opRunTests: 199 | return [self runTests:[op filename]]; 200 | } 201 | } 202 | @finally { 203 | [self finalizeOutput]; 204 | } 205 | return -42; 206 | } 207 | 208 | @end 209 | -------------------------------------------------------------------------------- /apexLoader/common/credential.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "credential.h" 23 | 24 | @implementation NSURL (Keychain) 25 | - (SecProtocolType)SecProtocolType { 26 | return [[[self scheme] lowercaseString] isEqualToString:@"http"] ? kSecProtocolTypeHTTP : kSecProtocolTypeHTTPS; 27 | } 28 | @end 29 | 30 | @implementation Credential 31 | 32 | + (NSArray *)credentialsForServer:(NSString *)protocolAndServer { 33 | NSURL *url = [NSURL URLWithString:protocolAndServer]; 34 | NSString *server = [url host]; 35 | SecProtocolType protocol = [url SecProtocolType]; 36 | 37 | NSMutableArray *results = [NSMutableArray array]; 38 | SecKeychainAttribute att[] = { {kSecServerItemAttr, [server length], (void *)[server UTF8String] }, 39 | {kSecProtocolItemAttr, sizeof(SecProtocolType), &protocol } }; 40 | SecKeychainAttributeList attList = { 2, att }; 41 | SecKeychainItemRef itemRef; 42 | SecKeychainSearchRef searchRef; 43 | OSStatus status = SecKeychainSearchCreateFromAttributes ( NULL, kSecInternetPasswordItemClass, &attList, &searchRef ); 44 | if (status == noErr) { 45 | status = SecKeychainSearchCopyNext(searchRef, &itemRef); 46 | while (status == noErr) { 47 | SecKeychainAttribute a[] = { { kSecAccountItemAttr, 0, NULL } }; 48 | SecKeychainAttributeList al = { 1, a }; 49 | OSStatus s2 = SecKeychainItemCopyContent(itemRef, NULL, &al, 0, NULL); 50 | if (noErr == s2) { 51 | NSString *un = [NSString stringWithCString:a[0].data length:a[0].length]; 52 | [results addObject:[Credential forServer:protocolAndServer username:un keychainItem:itemRef]]; 53 | SecKeychainItemFreeContent(&al, NULL); 54 | } else { 55 | NSLog(@"SecKeychainItemCopyAttributesAndData error %d", s2); 56 | // no need to release itemRef in the normal caseas the Credential object will own it 57 | CFRelease(itemRef); 58 | } 59 | status = SecKeychainSearchCopyNext(searchRef, &itemRef); 60 | } 61 | CFRelease(searchRef); 62 | } else { 63 | NSLog(@"SecKeychainSearchCreateFromAttributes returned error %d", status); 64 | } 65 | return results; 66 | } 67 | 68 | + (NSArray *)sortedCredentialsForServer:(NSString *)protocolAndServer { 69 | NSArray *credentials = [Credential credentialsForServer:protocolAndServer]; 70 | NSSortDescriptor *sortDesc = [[NSSortDescriptor alloc] initWithKey:@"username" ascending:YES]; 71 | NSArray *sorted = [credentials sortedArrayUsingDescriptors:[NSArray arrayWithObject:sortDesc]]; 72 | [sortDesc release]; 73 | return sorted; 74 | } 75 | 76 | + (id)forServer:(NSString *)server username:(NSString *)un keychainItem:(SecKeychainItemRef)kcItem { 77 | return [[[Credential alloc] initForServer:server username:un keychainItem:kcItem] autorelease]; 78 | } 79 | 80 | + (id)createCredentialForServer:(NSString *)protocolAndServer username:(NSString *)un password:(NSString *)pwd { 81 | NSURL *url = [NSURL URLWithString:protocolAndServer]; 82 | NSString *server = [url host]; 83 | SecKeychainItemRef itemRef; 84 | OSStatus status = SecKeychainAddInternetPassword ( 85 | NULL, 86 | [server cStringLength], [server cString], 87 | 0, NULL, 88 | [un lengthOfBytesUsingEncoding:NSUTF8StringEncoding], 89 | [un cStringUsingEncoding:NSUTF8StringEncoding], 90 | 0, NULL, 91 | 0, 92 | [url SecProtocolType], 93 | kSecAuthenticationTypeDefault, 94 | [pwd lengthOfBytesUsingEncoding:NSUTF8StringEncoding], 95 | [pwd cStringUsingEncoding:NSUTF8StringEncoding], 96 | &itemRef); 97 | if (status != noErr) { 98 | NSLog(@"SecKeychainAddInternetPassword returned error %d", status); 99 | return nil; 100 | } 101 | return [Credential forServer:protocolAndServer username:un keychainItem:itemRef]; 102 | } 103 | 104 | - (id)initForServer:(NSString *)s username:(NSString *)un keychainItem:(SecKeychainItemRef)kcItem { 105 | self = [super init]; 106 | server = [s copy]; 107 | username = [un copy]; 108 | keychainItem = kcItem; 109 | return self; 110 | } 111 | 112 | - (void)dealloc { 113 | [server release]; 114 | [username release]; 115 | CFRelease(keychainItem); 116 | [super dealloc]; 117 | } 118 | 119 | - (NSString *)description { 120 | return [NSString stringWithFormat:@"%@ at %@", username, server]; 121 | } 122 | 123 | - (NSString *)server { 124 | return server; 125 | } 126 | 127 | - (NSString *)username { 128 | return username; 129 | } 130 | 131 | - (NSString *)password { 132 | SecKeychainAttribute a[] = { { 0, 0, NULL } }; 133 | SecKeychainAttributeList al = { 0, a }; 134 | UInt32 length = 0; 135 | void *data = 0; 136 | NSString *pwd; 137 | if (noErr == SecKeychainItemCopyContent(keychainItem, NULL, &al, &length, &data)) { 138 | pwd = [NSString stringWithCString:data length:length]; 139 | } 140 | SecKeychainItemFreeContent(&al, data); 141 | return pwd; 142 | } 143 | 144 | - (void)removeFromKeychain { 145 | SecKeychainItemDelete(keychainItem); 146 | } 147 | 148 | BOOL checkAccessToAcl(SecACLRef acl, NSData *thisAppHash) { 149 | NSArray *apps; 150 | NSString *desc; 151 | CSSM_ACL_KEYCHAIN_PROMPT_SELECTOR ps; 152 | OSStatus err = SecACLCopySimpleContents(acl, (CFArrayRef *)&apps, (CFStringRef *)&desc, &ps); 153 | BOOL res = NO; 154 | if (err == noErr) { 155 | if (apps == nil) { 156 | res = YES; // from the docs, if the app list is null, anyone can access the entry 157 | } else { 158 | // see if we're in the list of apps 159 | NSData *aData; 160 | SecTrustedApplicationRef a; 161 | NSEnumerator *e = [apps objectEnumerator]; 162 | while (a = (SecTrustedApplicationRef)[e nextObject]) { 163 | SecTrustedApplicationCopyData(a, (CFDataRef *)&aData); 164 | if ([aData isEqualToData:thisAppHash]) res = YES; 165 | CFRelease(aData); 166 | if (res) break; 167 | } 168 | CFRelease(apps); 169 | } 170 | CFRelease(desc); 171 | } else { 172 | NSLog(@"SecACLCopySimpleContents failed with error %d", err); 173 | } 174 | return res; 175 | } 176 | 177 | - (BOOL)canReadPasswordWithoutPrompt { 178 | SecTrustedApplicationRef app; 179 | OSStatus err = SecTrustedApplicationCreateFromPath(NULL, &app); 180 | if (noErr != err) { 181 | NSLog(@"SecTrustedApplicationCreateFromPath failed with error %d", err); 182 | return NO; 183 | } 184 | NSData *thisAppHash; 185 | BOOL res = NO; 186 | err = SecTrustedApplicationCopyData(app, (CFDataRef *)&thisAppHash); 187 | if (err == noErr) { 188 | SecAccessRef access; 189 | err = SecKeychainItemCopyAccess(keychainItem, &access); 190 | if (noErr == err) { 191 | NSArray *acls; 192 | err = SecAccessCopySelectedACLList(access, CSSM_ACL_AUTHORIZATION_DECRYPT, (CFArrayRef *)&acls); 193 | if (noErr == err) { 194 | SecACLRef acl; 195 | NSEnumerator *e = [acls objectEnumerator]; 196 | while (acl = (SecACLRef)[e nextObject]) { 197 | res = checkAccessToAcl(acl, thisAppHash); 198 | if (res) break; 199 | } 200 | CFRelease(acls); 201 | } else { 202 | NSLog(@"SecAccessCopySelectedACLList failed with error %d", err); 203 | } 204 | CFRelease(access); 205 | } else { 206 | NSLog(@"SecKeychainItemCopyAccess failed with error %d", err); 207 | } 208 | CFRelease(thisAppHash); 209 | } else { 210 | NSLog(@"SecTrustedApplicationCopyData failed with error %d", err); 211 | } 212 | CFRelease(app); 213 | return res; 214 | } 215 | 216 | - (OSStatus)setKeychainAttribute:(SecItemAttr)attribute newValue:(NSString *)val newPassword:(NSString *)password { 217 | // Set up attribute vector (each attribute consists of {tag, length, pointer}): 218 | SecKeychainAttribute attrs[] = { 219 | { attribute, [val lengthOfBytesUsingEncoding:NSUTF8StringEncoding], (char *)[val cStringUsingEncoding:NSUTF8StringEncoding] } }; 220 | const SecKeychainAttributeList attributes = { sizeof(attrs) / sizeof(attrs[0]), attrs }; 221 | OSStatus status = SecKeychainItemModifyAttributesAndData ( 222 | keychainItem, // the item reference 223 | &attributes, // no change to attributes 224 | [password lengthOfBytesUsingEncoding:NSUTF8StringEncoding], 225 | [password cStringUsingEncoding:NSUTF8StringEncoding] ); 226 | if (status != noErr) 227 | NSLog(@"SecKeychainItemModifyAttributesAndData returned %d", status); 228 | return status; 229 | } 230 | 231 | - (void)setServer:(NSString *)protocolAndServer { 232 | NSURL *url = [NSURL URLWithString:protocolAndServer]; 233 | NSString *host = [url host]; 234 | SecProtocolType protocol = [url SecProtocolType]; 235 | 236 | // Set up attribute vector (each attribute consists of {tag, length, pointer}): 237 | SecKeychainAttribute attrs[] = { {kSecServerItemAttr, [host length], (void *)[host UTF8String] }, 238 | {kSecProtocolItemAttr, sizeof(SecProtocolType), &protocol } }; 239 | 240 | const SecKeychainAttributeList attributes = { sizeof(attrs) / sizeof(attrs[0]), attrs }; 241 | OSStatus status = SecKeychainItemModifyAttributesAndData ( 242 | keychainItem, // the item reference 243 | &attributes, // no change to attributes 244 | 0, 245 | nil ); 246 | if (status == noErr) { 247 | [server release]; 248 | server = [protocolAndServer copy]; 249 | } 250 | NSAssert(noErr == status, @"Unable to set server name in keychain entry"); 251 | } 252 | 253 | - (void)setUsername:(NSString *)newUsername { 254 | NSAssert(noErr == [self update:newUsername password:nil], @"Unable to set username attribute in keychain entry"); 255 | } 256 | 257 | - (void)setPassword:(NSString *)newPassword { 258 | NSAssert(noErr == [self update:username password:newPassword], @"Unable to set password attribute in keychain entry"); 259 | } 260 | 261 | - (OSStatus)update:(NSString *)newUsername password:(NSString *)newPassword { 262 | OSStatus status = [self setKeychainAttribute:kSecAccountItemAttr newValue:newUsername newPassword:newPassword]; 263 | if (status == noErr) { 264 | [username autorelease]; 265 | username = [newUsername copy]; 266 | } 267 | return status; 268 | } 269 | 270 | - (NSString *)stringAttribute:(int)attributeToRead { 271 | SecKeychainAttribute a[] = { { attributeToRead, 0, NULL } }; 272 | SecKeychainAttributeList al = { 1, a }; 273 | NSString *comment = nil; 274 | if (noErr == SecKeychainItemCopyContent(keychainItem, NULL, &al, nil, nil)) { 275 | comment = [NSString stringWithCString:a[0].data length:a[0].length]; 276 | } 277 | SecKeychainItemFreeContent(&al, nil); 278 | return comment; 279 | } 280 | 281 | - (NSString *)comment { 282 | return [self stringAttribute:kSecCommentItemAttr]; 283 | } 284 | 285 | - (NSString *)creator { 286 | return [self stringAttribute:kSecCreatorItemAttr]; 287 | } 288 | 289 | - (void)setComment:(NSString *)newComment { 290 | NSAssert(noErr == [self setKeychainAttribute:kSecCommentItemAttr newValue:newComment newPassword:nil], @"Unable to set comment attribute in keychain entry"); 291 | } 292 | 293 | - (void)setCreator:(NSString *)newCreator { 294 | NSAssert(noErr == [self setKeychainAttribute:kSecCreatorItemAttr newValue:newCreator newPassword:nil], @"Unable to set creator attribute in keychain entry"); 295 | } 296 | 297 | @end 298 | -------------------------------------------------------------------------------- /apexLoader/common/ZKLoginController.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006-2008 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | #import "ZKLoginController.h" 23 | #import "credential.h" 24 | #import "zkSforceClient.h" 25 | #import "zkSoapException.h" 26 | 27 | @implementation ZKLoginController 28 | 29 | static NSString * login_lastUsernameKey = @"login_lastUserName"; 30 | 31 | + (void)initialize { 32 | [self setKeys:[NSArray arrayWithObject:@"server"] triggerChangeNotificationsForDependentKey:@"credentials"]; 33 | [self setKeys:[NSArray arrayWithObject:@"server"] triggerChangeNotificationsForDependentKey:@"canDeleteServer"]; 34 | [self setKeys:[NSArray arrayWithObject:@"username"] triggerChangeNotificationsForDependentKey:@"password"]; 35 | } 36 | 37 | - (id)init { 38 | self = [super init]; 39 | server = [[[NSUserDefaults standardUserDefaults] objectForKey:@"server"] copy]; 40 | [self setUsername:[[NSUserDefaults standardUserDefaults] objectForKey:login_lastUsernameKey]]; 41 | return self; 42 | } 43 | 44 | - (void)setImage:(NSString *)name onButton:(NSButton *)b { 45 | NSString *imgFile = [[NSBundle mainBundle] pathForResource:name ofType:@"png"]; 46 | NSImage *img = [[[NSImage alloc] initWithContentsOfFile:imgFile] autorelease]; 47 | [b setImage:img]; 48 | } 49 | 50 | - (void)awakeFromNib { 51 | [self setImage:@"plus-8" onButton:addButton]; 52 | [self setImage:@"minus-8" onButton:delButton]; 53 | [loginProgress setUsesThreadedAnimation:YES]; 54 | [loginProgress setHidden:YES]; 55 | [loginProgress setDoubleValue:22.0]; 56 | } 57 | 58 | - (void)dealloc { 59 | [username release]; 60 | [password release]; 61 | [server release]; 62 | [clientId release]; 63 | [credentials release]; 64 | [selectedCredential release]; 65 | [sforce release]; 66 | [newUrl release]; 67 | [super dealloc]; 68 | } 69 | 70 | - (void)loadNib { 71 | [NSBundle loadNibNamed:@"Login" owner:self]; 72 | } 73 | 74 | - (void)setClientIdFromInfoPlist { 75 | NSDictionary *plist = [[NSBundle mainBundle] infoDictionary]; 76 | NSString *cid = [NSString stringWithFormat:@"%@/%@", [plist objectForKey:@"CFBundleName"], [plist objectForKey:@"CFBundleVersion"]]; 77 | [self setClientId:cid]; 78 | } 79 | 80 | - (void)endModalWindow:(id)sforce { 81 | [NSApp stopModal]; 82 | } 83 | 84 | - (ZKSforceClient *)showModalLoginWindow:(id)sender { 85 | [self loadNib]; 86 | target = self; 87 | selector = @selector(endModalWindow:); 88 | modalWindow = nil; 89 | [NSApp runModalForWindow:window]; 90 | [window close]; 91 | return [sforce loggedIn] ? sforce : nil; 92 | } 93 | 94 | - (void)showLoginWindow:(id)sender target:(id)t selector:(SEL)s { 95 | [self loadNib]; 96 | target = t; 97 | selector = s; 98 | modalWindow = nil; 99 | [window makeKeyAndOrderFront:sender]; 100 | } 101 | 102 | - (void)showLoginSheet:(NSWindow *)modalForWindow target:(id)t selector:(SEL)s { 103 | [self loadNib]; 104 | target = t; 105 | selector = s; 106 | modalWindow = modalForWindow; 107 | [NSApp beginSheet:window modalForWindow:modalForWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; 108 | } 109 | 110 | - (void)restoreLoginWindow:(NSWindow *)w returnCode:(int)rc contextInfo:(id)ctx { 111 | if (modalWindow != nil) { 112 | [w orderOut:self]; 113 | [NSApp beginSheet:window modalForWindow:modalWindow modalDelegate:self didEndSelector:nil contextInfo:nil]; 114 | } 115 | } 116 | 117 | static NSString *prod = @"https://www.salesforce.com"; 118 | static NSString *test = @"https://test.salesforce.com"; 119 | 120 | - (BOOL)canDeleteServer { 121 | return ([server caseInsensitiveCompare:prod] != NSOrderedSame) && ([server caseInsensitiveCompare:test] != NSOrderedSame); 122 | } 123 | 124 | - (IBAction)showAddNewServer:(id)sender { 125 | [self setNewUrl:@"https://"]; 126 | if (modalWindow != nil) { 127 | [NSApp endSheet:window]; 128 | [window orderOut:sender]; 129 | } 130 | [NSApp beginSheet:newUrlWindow modalForWindow:modalWindow == nil ? window : modalWindow modalDelegate:self didEndSelector:@selector(restoreLoginWindow:returnCode:contextInfo:) contextInfo:nil]; 131 | } 132 | 133 | - (IBAction)closeAddNewServer:(id)sender { 134 | [NSApp endSheet:newUrlWindow]; 135 | [newUrlWindow orderOut:sender]; 136 | } 137 | 138 | - (IBAction)deleteServer:(id)sender { 139 | if (![self canDeleteServer]) return; 140 | NSArray *servers = [[NSUserDefaults standardUserDefaults] objectForKey:@"servers"]; 141 | NSMutableArray *newServers = [NSMutableArray arrayWithCapacity:[servers count]]; 142 | NSString *s; 143 | NSEnumerator *e = [servers objectEnumerator]; 144 | while (s = [e nextObject]) { 145 | if ([s caseInsensitiveCompare:server] == NSOrderedSame) continue; 146 | [newServers addObject:s]; 147 | } 148 | [[NSUserDefaults standardUserDefaults] setObject:newServers forKey:@"servers"]; 149 | [self setServer:prod]; 150 | } 151 | 152 | - (IBAction)addNewServer:(id)sender { 153 | NSString *new = [self newUrl]; 154 | if (![new isEqualToString:@"https://"]) { 155 | NSArray *servers = [[NSUserDefaults standardUserDefaults] objectForKey:@"servers"]; 156 | if (![servers containsObject:new]) { 157 | NSMutableArray *newServers = [NSMutableArray array]; 158 | [newServers addObjectsFromArray:servers]; 159 | [newServers addObject:new]; 160 | [[NSUserDefaults standardUserDefaults] setObject:newServers forKey:@"servers"]; 161 | } 162 | [self setServer:new]; 163 | [self closeAddNewServer:sender]; 164 | } 165 | } 166 | 167 | - (IBAction)cancelLogin:(id)sender { 168 | if (target == self) { 169 | [NSApp stopModal]; 170 | } else if (modalWindow != nil) { 171 | [NSApp endSheet:window]; 172 | [window orderOut:sender]; 173 | } else { 174 | [window close]; 175 | } 176 | } 177 | 178 | - (Credential *)selectedCredential { 179 | return selectedCredential; 180 | } 181 | 182 | - (void)setSelectedCredential:(Credential *)aValue { 183 | Credential *oldSelectedCredential = selectedCredential; 184 | selectedCredential = [aValue retain]; 185 | [oldSelectedCredential release]; 186 | } 187 | 188 | - (void)showAlertSheetWithMessageText:(NSString *)message 189 | defaultButton:(NSString *)defaultButton 190 | altButton:(NSString *)altButton 191 | otherButton:(NSString *)otherButton 192 | additionalText:(NSString *)additionalText 193 | didEndSelector:(SEL)didEndSelector 194 | contextInfo:(id)context { 195 | NSAlert * a = [NSAlert alertWithMessageText:message defaultButton:defaultButton alternateButton:altButton otherButton:otherButton informativeTextWithFormat:additionalText]; 196 | NSWindow *wndForAlertSheet = modalWindow == nil ? window : modalWindow; 197 | if (modalWindow != nil) { 198 | [NSApp endSheet:window]; 199 | [window orderOut:self]; 200 | } 201 | [a beginSheetModalForWindow:(NSWindow *)wndForAlertSheet modalDelegate:self didEndSelector:didEndSelector contextInfo:context]; 202 | } 203 | 204 | - (void)updateKeychain:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { 205 | // NSLog(@"updateKeychain rc=%d", returnCode); 206 | if (returnCode == NSAlertDefaultReturn) 207 | [[self selectedCredential] update:username password:password]; 208 | [[alert window] orderOut:self]; 209 | [self cancelLogin:self]; 210 | [target performSelector:selector withObject:sforce]; 211 | } 212 | 213 | - (void)createKeychain:(NSAlert *)alert returnCode:(int)returnCode contextInfo:(void *)contextInfo { 214 | // NSLog(@"createKeychain rc=%d", returnCode); 215 | if (returnCode == NSAlertDefaultReturn) 216 | [Credential createCredentialForServer:server username:username password:password]; 217 | [[alert window] orderOut:self]; 218 | [self cancelLogin:self]; 219 | [target performSelector:selector withObject:sforce]; 220 | } 221 | 222 | - (void)promptAndAddToKeychain { 223 | [self showAlertSheetWithMessageText:@"Crete Keychain entry with new username & password?" 224 | defaultButton:@"Create Keychain Entry" 225 | altButton:@"No thanks" 226 | otherButton:nil 227 | additionalText:@"" 228 | didEndSelector:@selector(createKeychain:returnCode:contextInfo:) 229 | contextInfo:nil]; 230 | } 231 | 232 | - (void)promptAndUpdateKeychain { 233 | [self showAlertSheetWithMessageText:@"Update Keychain entry with new password?" 234 | defaultButton:@"Update Keychain" 235 | altButton:@"No thanks" 236 | otherButton:nil 237 | additionalText:@"" 238 | didEndSelector:@selector(updateKeychain:returnCode:contextInfo:) 239 | contextInfo:nil]; 240 | } 241 | 242 | - (ZKSforceClient *)performLogin:(ZKSoapException **)error { 243 | [sforce release]; 244 | sforce = [[ZKSforceClient alloc] init]; 245 | [sforce setLoginProtocolAndHost:server]; 246 | if ([clientId length] > 0) 247 | [sforce setClientId:clientId]; 248 | @try { 249 | [sforce login:username password:password]; 250 | [[NSUserDefaults standardUserDefaults] setObject:server forKey:@"server"]; 251 | [[NSUserDefaults standardUserDefaults] setObject:username forKey:login_lastUsernameKey]; 252 | } 253 | @catch (ZKSoapException *ex) { 254 | if (error != nil) *error = ex; 255 | return nil; 256 | } 257 | return sforce; 258 | } 259 | 260 | - (IBAction)login:(id)sender { 261 | [self setStatusText:nil]; 262 | [loginProgress setHidden:NO]; 263 | [loginProgress display]; 264 | @try { 265 | ZKSoapException *ex = nil; 266 | [self performLogin:&ex]; 267 | if (ex != nil) { 268 | [self setStatusText:[ex reason]]; 269 | return; 270 | } 271 | if (selectedCredential == nil || (![[[selectedCredential username] lowercaseString] isEqualToString:[username lowercaseString]])) { 272 | [self promptAndAddToKeychain]; 273 | return; 274 | } 275 | else if (![[selectedCredential password] isEqualToString:password]) { 276 | [self promptAndUpdateKeychain]; 277 | return; 278 | } 279 | [self cancelLogin:sender]; 280 | [target performSelector:selector withObject:sforce]; 281 | } 282 | @finally { 283 | [loginProgress setHidden:YES]; 284 | [loginProgress display]; 285 | } 286 | } 287 | 288 | - (NSArray *)credentials { 289 | if (credentials == nil) { 290 | // NSComboBox doesn't really bind to an object, its value is always the display string 291 | // regardless of how many you have with the same name, it doesn't bind the value to 292 | // the underlying object (lame), so we filter out all the duplicate usernames 293 | NSArray *allCredentials = [Credential credentialsForServer:server]; 294 | NSMutableArray * filtered = [NSMutableArray arrayWithCapacity:[allCredentials count]]; 295 | NSMutableSet *usernames = [NSMutableSet set]; 296 | Credential *c; 297 | NSEnumerator *e = [allCredentials objectEnumerator]; 298 | while (c = [e nextObject]) { 299 | if ([usernames containsObject:[[c username] lowercaseString]]) continue; 300 | [usernames addObject:[[c username] lowercaseString]]; 301 | [filtered addObject:c]; 302 | } 303 | credentials = [filtered retain]; 304 | } 305 | return credentials; 306 | } 307 | 308 | - (NSString *)server { 309 | return server; 310 | } 311 | 312 | - (void)setPasswordFromKeychain { 313 | // see if there's a matching credential and default the password if so 314 | Credential *c; 315 | NSEnumerator *e = [[self credentials] objectEnumerator]; 316 | while (c = [e nextObject]) { 317 | if ([[c username] caseInsensitiveCompare:username] == NSOrderedSame) { 318 | [self setPassword:[c password]]; 319 | [self setSelectedCredential:c]; 320 | return; 321 | } 322 | } 323 | [self setSelectedCredential:nil]; 324 | } 325 | 326 | - (void)setServer:(NSString *)aServer { 327 | if ([server isEqualToString:aServer]) return; 328 | [server release]; 329 | server = [aServer copy]; 330 | [credentials release]; 331 | credentials = nil; 332 | [self setSelectedCredential:nil]; 333 | // we've changed server, so we need to recalc the password 334 | [self setPasswordFromKeychain]; 335 | } 336 | 337 | - (NSString *)password { 338 | return password; 339 | } 340 | 341 | - (void)setPassword:(NSString *)aPassword { 342 | aPassword = [aPassword copy]; 343 | [password release]; 344 | password = aPassword; 345 | } 346 | 347 | - (NSString *)username { 348 | return username; 349 | } 350 | 351 | - (void)setUsername:(NSString *)aUsername { 352 | aUsername = [aUsername copy]; 353 | [username release]; 354 | username = aUsername; 355 | [self setPasswordFromKeychain]; 356 | } 357 | 358 | - (NSString *)clientId { 359 | return clientId; 360 | } 361 | 362 | - (void)setClientId:(NSString *)aClientId { 363 | aClientId = [aClientId copy]; 364 | [clientId release]; 365 | clientId = aClientId; 366 | } 367 | 368 | - (NSString *)newUrl { 369 | return newUrl; 370 | } 371 | 372 | - (void)setNewUrl:(NSString *)aNewUrl { 373 | aNewUrl = [aNewUrl copy]; 374 | [newUrl release]; 375 | newUrl = aNewUrl; 376 | } 377 | 378 | - (NSString *)statusText { 379 | return statusText; 380 | } 381 | 382 | - (void)setStatusText:(NSString *)aStatusText { 383 | aStatusText = [aStatusText copy]; 384 | [statusText release]; 385 | statusText = aStatusText; 386 | } 387 | 388 | @end 389 | -------------------------------------------------------------------------------- /apexLoader/sforce/zkSforceClient.m: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2006,2011 Simon Fell 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a 4 | // copy of this software and associated documentation files (the "Software"), 5 | // to deal in the Software without restriction, including without limitation 6 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 7 | // and/or sell copies of the Software, and to permit persons to whom the 8 | // Software is furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included 11 | // in all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | // 21 | 22 | 23 | #import "zkSforceClient.h" 24 | #import "zkPartnerEnvelope.h" 25 | #import "zkQueryResult.h" 26 | #import "zkSaveResult.h" 27 | #import "zkSObject.h" 28 | #import "zkSoapException.h" 29 | #import "zkUserInfo.h" 30 | #import "zkDescribeSObject.h" 31 | 32 | static const int MAX_SESSION_AGE = 25 * 60; // 25 minutes 33 | static const int SAVE_BATCH_SIZE = 25; 34 | 35 | @interface ZKSforceClient (Private) 36 | - (ZKQueryResult *)queryImpl:(NSString *)value operation:(NSString *)op name:(NSString *)elemName; 37 | - (NSArray *)sobjectsImpl:(NSArray *)objects name:(NSString *)elemName; 38 | - (void)checkSession; 39 | - (void)startNewSession; 40 | @end 41 | 42 | @implementation ZKSforceClient 43 | 44 | - (id)init { 45 | self = [super init]; 46 | [self setLoginProtocolAndHost:@"https://www.salesforce.com"]; 47 | updateMru = NO; 48 | cacheDescribes = NO; 49 | return self; 50 | } 51 | 52 | - (void)dealloc { 53 | [authEndpointUrl release]; 54 | [username release]; 55 | [password release]; 56 | [clientId release]; 57 | [sessionId release]; 58 | [sessionExpiresAt release]; 59 | [userInfo release]; 60 | [describes release]; 61 | [super dealloc]; 62 | } 63 | 64 | - (id)copyWithZone:(NSZone *)zone { 65 | ZKSforceClient *rhs = [[ZKSforceClient alloc] init]; 66 | [rhs->authEndpointUrl release]; 67 | rhs->authEndpointUrl = [authEndpointUrl copy]; 68 | rhs->endpointUrl = [endpointUrl copy]; 69 | rhs->sessionId = [sessionId copy]; 70 | rhs->username = [username copy]; 71 | rhs->password = [password copy]; 72 | rhs->clientId = [clientId copy]; 73 | rhs->sessionExpiresAt = [sessionExpiresAt copy]; 74 | rhs->userInfo = [userInfo retain]; 75 | [rhs setCacheDescribes:cacheDescribes]; 76 | [rhs setUpdateMru:updateMru]; 77 | return rhs; 78 | } 79 | 80 | - (BOOL)updateMru { 81 | return updateMru; 82 | } 83 | 84 | - (void)setUpdateMru:(BOOL)aValue { 85 | updateMru = aValue; 86 | } 87 | 88 | - (BOOL)cacheDescribes { 89 | return cacheDescribes; 90 | } 91 | 92 | - (void)setCacheDescribes:(BOOL)newCacheDescribes { 93 | if (cacheDescribes == newCacheDescribes) return; 94 | cacheDescribes = newCacheDescribes; 95 | [self flushCachedDescribes]; 96 | } 97 | 98 | - (void)flushCachedDescribes { 99 | [describes release]; 100 | describes = nil; 101 | if (cacheDescribes) 102 | describes = [[NSMutableDictionary alloc] init]; 103 | } 104 | 105 | - (void)setLoginProtocolAndHost:(NSString *)protocolAndHost { 106 | [self setLoginProtocolAndHost:protocolAndHost andVersion:22]; 107 | } 108 | 109 | - (void)setLoginProtocolAndHost:(NSString *)protocolAndHost andVersion:(int)version { 110 | [authEndpointUrl release]; 111 | authEndpointUrl = [[NSString stringWithFormat:@"%@/services/Soap/u/%d.0", protocolAndHost, version] retain]; 112 | } 113 | 114 | - (void)login:(NSString *)un password:(NSString *)pwd { 115 | [userInfo release]; 116 | userInfo = nil; 117 | [password release]; 118 | [username release]; 119 | username = [un retain]; 120 | password = [pwd retain]; 121 | [self startNewSession]; 122 | } 123 | 124 | - (void)startNewSession { 125 | [sessionExpiresAt release]; 126 | sessionExpiresAt = [[NSDate dateWithTimeIntervalSinceNow:MAX_SESSION_AGE] retain]; 127 | [sessionId release]; 128 | [endpointUrl release]; 129 | endpointUrl = [authEndpointUrl copy]; 130 | 131 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:nil clientId:clientId]; 132 | [env startElement:@"login"]; 133 | [env addElement:@"username" elemValue:username]; 134 | [env addElement:@"password" elemValue:password]; 135 | [env endElement:@"login"]; 136 | [env endElement:@"s:Body"]; 137 | NSString *xml = [env end]; 138 | 139 | NSError *err = nil; 140 | NSXMLNode *resp = [self sendRequest:xml]; 141 | 142 | NSXMLNode *serverUrl = [[resp nodesForXPath:@"result/serverUrl" error:&err] objectAtIndex:0]; 143 | [endpointUrl release]; 144 | endpointUrl = [[serverUrl stringValue] copy]; 145 | 146 | NSXMLNode *sid = [[resp nodesForXPath:@"result/sessionId" error:&err] objectAtIndex:0]; 147 | sessionId = [[sid stringValue] copy]; 148 | 149 | NSXMLNode *ui = [[resp nodesForXPath:@"result/userInfo" error:&err] objectAtIndex:0]; 150 | userInfo = [[ZKUserInfo alloc] initWithXmlElement:(NSXMLElement*)ui]; 151 | [env release]; 152 | } 153 | 154 | - (BOOL)loggedIn { 155 | return [sessionId length] > 0; 156 | } 157 | 158 | - (void)checkSession { 159 | if ([sessionExpiresAt timeIntervalSinceNow] < 0) 160 | [self startNewSession]; 161 | } 162 | 163 | - (ZKUserInfo *)currentUserInfo { 164 | return userInfo; 165 | } 166 | 167 | - (NSString *)serverUrl { 168 | return endpointUrl; 169 | } 170 | 171 | - (NSString *)sessionId { 172 | [self checkSession]; 173 | return sessionId; 174 | } 175 | 176 | 177 | - (NSString *)clientId { 178 | return clientId; 179 | } 180 | 181 | - (void)setClientId:(NSString *)aClientId { 182 | aClientId = [aClientId copy]; 183 | [clientId release]; 184 | clientId = aClientId; 185 | } 186 | 187 | - (NSArray *)describeGlobal { 188 | if(!sessionId) return NULL; 189 | [self checkSession]; 190 | 191 | ZKEnvelope * env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 192 | [env startElement:@"describeGlobal"]; 193 | [env endElement:@"describeGlobal"]; 194 | [env endElement:@"s:Body"]; 195 | 196 | NSError * err = NULL; 197 | NSXMLNode * rr = [self sendRequest:[env end]]; 198 | NSMutableArray *types = [NSMutableArray array]; 199 | NSArray * results = [rr nodesForXPath:@"result/types" error:&err]; 200 | NSEnumerator * e = [results objectEnumerator]; 201 | while (rr = [e nextObject]) { 202 | [types addObject:[rr stringValue]]; 203 | } 204 | [env release]; 205 | return types; 206 | } 207 | 208 | - (ZKDescribeSObject *)describeSObject:(NSString *)sobjectName { 209 | if (!sessionId) return NULL; 210 | if (cacheDescribes) { 211 | ZKDescribeSObject * desc = [describes objectForKey:[sobjectName lowercaseString]]; 212 | if (desc != nil) return desc; 213 | } 214 | [self checkSession]; 215 | 216 | ZKEnvelope * env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 217 | [env startElement:@"describeSObject"]; 218 | [env addElement:@"SobjectType" elemValue:sobjectName]; 219 | [env endElement:@"describeSObject"]; 220 | [env endElement:@"s:Body"]; 221 | 222 | NSError *err = 0; 223 | NSXMLNode *dr = [self sendRequest:[env end]]; 224 | NSXMLNode *descResult = [[dr nodesForXPath:@"result" error:&err] objectAtIndex:0]; 225 | ZKDescribeSObject *desc = [[[ZKDescribeSObject alloc] initWithXmlElement:(NSXMLElement*)descResult] autorelease]; 226 | [env release]; 227 | if (cacheDescribes) 228 | [describes setObject:desc forKey:[sobjectName lowercaseString]]; 229 | return desc; 230 | } 231 | 232 | - (NSArray *)search:(NSString *)sosl { 233 | if (!sessionId) return NULL; 234 | [self checkSession]; 235 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 236 | [env startElement:@"search"]; 237 | [env addElement:@"searchString" elemValue:sosl]; 238 | [env endElement:@"search"]; 239 | [env endElement:@"s:Body"]; 240 | 241 | NSError *err = 0; 242 | NSXMLNode *sr = [self sendRequest:[env end]]; 243 | NSXMLNode *searchResult = [[sr nodesForXPath:@"result" error:&err] objectAtIndex:0]; 244 | NSArray *records = [searchResult nodesForXPath:@"searchRecords/record" error:&err]; 245 | NSMutableArray *sobjects = [NSMutableArray array]; 246 | NSEnumerator *e = [records objectEnumerator]; 247 | NSXMLNode *soNode; 248 | while (soNode = [e nextObject]) 249 | [sobjects addObject:[ZKSObject fromXmlNode:soNode]]; 250 | [env release]; 251 | return sobjects; 252 | } 253 | 254 | - (NSString *)serverTimestamp { 255 | if (!sessionId) return NULL; 256 | [self checkSession]; 257 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 258 | [env startElement:@"getServerTimestamp"]; 259 | [env endElement:@"getServerTimestamp"]; 260 | [env endElement:@"s:Body"]; 261 | 262 | NSError *err = 0; 263 | NSXMLNode *res = [self sendRequest:[env end]]; 264 | NSXMLNode *timestamp = [[res nodesForXPath:@"result" error:&err] objectAtIndex:0]; 265 | [env release]; 266 | return [timestamp stringValue]; 267 | } 268 | 269 | - (ZKQueryResult *)query:(NSString *) soql { 270 | return [self queryImpl:soql operation:@"query" name:@"queryString"]; 271 | } 272 | 273 | - (ZKQueryResult *)queryAll:(NSString *) soql { 274 | return [self queryImpl:soql operation:@"queryAll" name:@"queryString"]; 275 | } 276 | 277 | - (ZKQueryResult *)queryMore:(NSString *)queryLocator { 278 | return [self queryImpl:queryLocator operation:@"queryMore" name:@"queryLocator"]; 279 | } 280 | 281 | - (NSArray *)create:(NSArray *)objects { 282 | return [self sobjectsImpl:objects name:@"create"]; 283 | } 284 | 285 | - (NSArray *)update:(NSArray *)objects { 286 | return [self sobjectsImpl:objects name:@"update"]; 287 | } 288 | 289 | - (NSArray *)upsert:(NSString *)extIdFieldName objects:(NSArray *)objects { 290 | if (!sessionId) return NULL; 291 | [self checkSession]; 292 | 293 | ZKEnvelope *env = [[[ZKPartnerEnvelope alloc] initWithSessionAndMruHeaders:sessionId mru:updateMru clientId:clientId] autorelease]; 294 | [env startElement:@"upsert"]; 295 | [env addElement:@"externalIDFieldName" elemValue:extIdFieldName]; 296 | [env addElementArray:@"sobjects" elemValue:objects]; 297 | [env endElement:@"upsert"]; 298 | [env endElement:@"s:Body"]; 299 | 300 | NSError *err = NULL; 301 | NSXMLNode *cr = [self sendRequest:[env end]]; 302 | NSArray *resultsArr = [cr nodesForXPath:@"result" error:&err]; 303 | NSMutableArray *results = [NSMutableArray arrayWithCapacity:[resultsArr count]]; 304 | for (NSXMLNode *cr in resultsArr) { 305 | ZKSaveResult * sr = [[ZKSaveResult alloc] initWithXmlElement:(NSXMLElement*)cr]; 306 | [results addObject:sr]; 307 | [sr release]; 308 | } 309 | return results; 310 | } 311 | 312 | - (NSArray *)sobjectsImpl:(NSArray *)objects name:(NSString *)elemName { 313 | if(!sessionId) return NULL; 314 | [self checkSession]; 315 | 316 | // if more than we can do in one go, break it up. 317 | if ([objects count] > SAVE_BATCH_SIZE) { 318 | NSMutableArray *allResults = [NSMutableArray arrayWithCapacity:[objects count]]; 319 | NSRange rng = {0, MIN(SAVE_BATCH_SIZE, [objects count])}; 320 | while (rng.location < [objects count]) { 321 | [allResults addObjectsFromArray:[self sobjectsImpl:[objects subarrayWithRange:rng] name:elemName]]; 322 | rng.location += rng.length; 323 | rng.length = MIN(SAVE_BATCH_SIZE, [objects count] - rng.location); 324 | } 325 | return allResults; 326 | } 327 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionAndMruHeaders:sessionId mru:updateMru clientId:clientId]; 328 | [env startElement:elemName]; 329 | NSEnumerator *e = [objects objectEnumerator]; 330 | ZKSObject *o; 331 | while (o = [e nextObject]) 332 | [env addElement:@"sobject" elemValue:o]; 333 | [env endElement:elemName]; 334 | [env endElement:@"s:Body"]; 335 | 336 | NSError *err = NULL; 337 | NSXMLNode *cr = [self sendRequest:[env end]]; 338 | NSArray *resultsArr = [cr nodesForXPath:@"result" error:&err]; 339 | NSMutableArray *results = [NSMutableArray arrayWithCapacity:[resultsArr count]]; 340 | e = [resultsArr objectEnumerator]; 341 | while (cr = [e nextObject]) { 342 | ZKSaveResult * sr = [[ZKSaveResult alloc] initWithXmlElement:(NSXMLElement*)cr]; 343 | [results addObject:sr]; 344 | [sr release]; 345 | } 346 | [env release]; 347 | return results; 348 | } 349 | 350 | - (NSDictionary *)retrieve:(NSString *)fields sobject:(NSString *)sobjectType ids:(NSArray *)ids { 351 | if(!sessionId) return NULL; 352 | [self checkSession]; 353 | 354 | ZKEnvelope * env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 355 | [env startElement:@"retrieve"]; 356 | [env addElement:@"fieldList" elemValue:fields]; 357 | [env addElement:@"sObjectType" elemValue:sobjectType]; 358 | [env addElementArray:@"ids" elemValue:ids]; 359 | [env endElement:@"retrieve"]; 360 | [env endElement:@"s:Body"]; 361 | 362 | NSError *err = NULL; 363 | NSXMLNode *rr = [self sendRequest:[env end]]; 364 | NSMutableDictionary *sobjects = [NSMutableDictionary dictionary]; 365 | NSArray *results = [rr nodesForXPath:@"result" error:&err]; 366 | NSEnumerator *e = [results objectEnumerator]; 367 | while (rr = [e nextObject]) { 368 | ZKSObject *o = [[ZKSObject alloc] initFromXmlNode:rr]; 369 | [sobjects setObject:o forKey:[o id]]; 370 | [o release]; 371 | } 372 | [env release]; 373 | return sobjects; 374 | } 375 | 376 | - (NSArray *)delete:(NSArray *)ids { 377 | if(!sessionId) return NULL; 378 | [self checkSession]; 379 | 380 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionAndMruHeaders:sessionId mru:updateMru clientId:clientId]; 381 | [env startElement:@"delete"]; 382 | [env addElement:@"ids" elemValue:ids]; 383 | [env endElement:@"delete"]; 384 | [env endElement:@"s:Body"]; 385 | 386 | NSError *err = NULL; 387 | NSXMLNode *cr = [self sendRequest:[env end]]; 388 | NSArray *resArr = [cr nodesForXPath:@"result" error:&err]; 389 | NSMutableArray *results = [NSMutableArray arrayWithCapacity:[resArr count]]; 390 | NSEnumerator *e = [resArr objectEnumerator]; 391 | while (cr = [e nextObject]) { 392 | ZKSaveResult *sr = [[ZKSaveResult alloc] initWithXmlElement:(NSXMLElement*)cr]; 393 | [results addObject:sr]; 394 | [sr release]; 395 | } 396 | [env release]; 397 | return results; 398 | } 399 | 400 | - (ZKQueryResult *)queryImpl:(NSString *)value operation:(NSString *)operation name:(NSString *)elemName { 401 | if(!sessionId) return NULL; 402 | [self checkSession]; 403 | 404 | ZKEnvelope *env = [[ZKPartnerEnvelope alloc] initWithSessionHeader:sessionId clientId:clientId]; 405 | [env startElement:operation]; 406 | [env addElement:elemName elemValue:value]; 407 | [env endElement:operation]; 408 | [env endElement:@"s:Body"]; 409 | 410 | NSXMLNode *qr = [self sendRequest:[env end]]; 411 | ZKQueryResult *result = [[ZKQueryResult alloc] initFromXmlNode:[[qr children] objectAtIndex:0]]; 412 | [env release]; 413 | return [result autorelease]; 414 | } 415 | 416 | @end 417 | --------------------------------------------------------------------------------