1 // ======================================================================
2 // File: KCOperationID.h
4 // OperationID must be registered so that a test script knows how to
5 // construct an appropriate KCOperation class
7 // Copyright: Copyright (c) 2000,2003 Apple Computer, Inc. All Rights Reserved.
9 // Change History (most recent first):
11 // <1> 2/22/00 em Created.
12 // ======================================================================
13 #ifndef __KC_OPERATION_ID__
14 #define __KC_OPERATION_ID__
18 OpID_COp_KCGetKeychainManagerVersion
= 0,
19 OpID_COp_KeychainManagerAvailable
,//1
20 OpID_COp_KCMakeKCRefFromFSRef
,//2
21 OpID_COp_KCMakeKCRefFromFSSpec
,//3
22 OpID_COp_KCMakeKCRefFromAlias
,//4
23 OpID_COp_KCMakeAliasFromKCRef
,//5
24 OpID_COp_KCReleaseKeychain
,//6
25 OpID_COp_KCUnlockNoUI
,//7
27 OpID_COp_KCUnlockWithInfo
,//9
29 OpID_COp_KCLockNoUI
,//11
30 OpID_COp_KCGetDefaultKeychain
,//12
31 OpID_COp_KCSetDefaultKeychain
,//13
32 OpID_COp_KCCreateKeychain
,//14
33 OpID_COp_KCCreateKeychainNoUI
,//15
34 OpID_COp_KCGetStatus
,//16
35 OpID_COp_KCChangeSettingsNoUI
,//17
36 OpID_COp_KCGetKeychain
,//18
37 OpID_COp_KCGetKeychainName
,//19
38 OpID_COp_KCChangeSettings
,//20
39 OpID_COp_KCCountKeychains
,//21
40 OpID_COp_KCGetIndKeychain
,//22
41 OpID_COp_KCAddCallback
,//23
42 OpID_COp_KCRemoveCallback
,//24
43 OpID_COp_KCSetInteractionAllowed
,//25
44 OpID_COp_KCIsInteractionAllowed
,//26
45 OpID_COp_KCAddAppleSharePassword
,//27
46 OpID_COp_KCFindAppleSharePassword
,//28
47 OpID_COp_KCAddInternetPassword
,//29
48 OpID_COp_KCAddInternetPasswordWithPath
,//30
49 OpID_COp_KCFindInternetPassword
,//31
50 OpID_COp_KCFindInternetPasswordWithPath
,//32
51 OpID_COp_KCAddGenericPassword
,//33
52 OpID_COp_KCFindGenericPassword
,//34
53 OpID_COp_KCNewItem
,//35
54 OpID_COp_KCSetAttribute
,//36
55 OpID_COp_KCGetAttribute
,//37
56 OpID_COp_KCSetData
,//38
57 OpID_COp_KCGetData
,//39
58 OpID_COp_KCGetDataNoUI
,//40
59 OpID_COp_KCAddItem
,//41
60 OpID_COp_KCAddItemNoUI
,//42
61 OpID_COp_KCDeleteItem
,//43
62 OpID_COp_KCDeleteItemNoUI
,//44
63 OpID_COp_KCUpdateItem
,//45
64 OpID_COp_KCReleaseItem
,//46
65 OpID_COp_KCCopyItem
,//47
66 OpID_COp_KCFindFirstItem
,//48
67 OpID_COp_KCFindNextItem
,//49
68 OpID_COp_KCReleaseSearch
,//50
69 OpID_COp_KCFindX509Certificates
,//51
70 OpID_COp_KCChooseCertificate
,//52
71 OpID_COp_kcunlock
,//53
72 OpID_COp_kccreatekeychain
,//54
73 OpID_COp_kcgetkeychainname
,//55
74 OpID_COp_kcaddapplesharepassword
,//56
75 OpID_COp_kcfindapplesharepassword
,//57
76 OpID_COp_kcaddinternetpassword
,//58
77 OpID_COp_kcaddinternetpasswordwithpath
,//59
78 OpID_COp_kcfindinternetpassword
,//60
79 OpID_COp_kcfindinternetpasswordwithpath
,//61
80 OpID_COp_kcaddgenericpassword
,//62
81 OpID_COp_kcfindgenericpassword
,//63
83 OpID_COp_KCLogout
,//65
84 OpID_COp_KCChangeLoginPassword
,//66
87 #define IS_VALID_OPERATIONID(aID) (aID >= 0 && aID < OpID_NumOperations)
89 typedef void * (*tClassCreatorFunc
)(void *inClient
);
90 typedef struct tOperationInfo
{
92 tClassCreatorFunc func
;
94 // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
96 // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
99 static void * CreateOperation(
104 if(IS_VALID_OPERATIONID(inID
)){
105 if(sOperationInfoTbl
[inID
].func
)
106 return (sOperationInfoTbl
[inID
].func
)(inClient
);
111 static const char * GetOperationName(
115 if(IS_VALID_OPERATIONID(inID
))
116 return sOperationInfoTbl
[inID
].name
;
118 return "INVALID OPERATION ID";
121 static void RegisterAll();
122 static void RegisterOne(
125 tClassCreatorFunc inFunc
= NULL
)
127 sOperationInfoTbl
[inID
].name
= inName
;
128 sOperationInfoTbl
[inID
].func
= inFunc
;
131 static bool sRegistered
;
132 static tOperationInfo sOperationInfoTbl
[OpID_NumOperations
];
140 T
*aOperation
= new T
;
141 if(aOperation
) aOperation
->SetClient(inClient
);
144 static void RegisterOne(
148 COpRegister::RegisterOne(inID
, inName
, (tClassCreatorFunc
)Create
);
152 // Relax notations so one can avoid typing long names
153 #define KC_CLASS(funcname) COp_## funcname
154 #define KC_OP_ID(funcname) OpID_COp_## funcname
155 #define Register(funcname) TOpRegister<KC_CLASS(funcname)>::RegisterOne(KC_OP_ID(funcname), (const char*)#funcname "")
156 #define OPERATION_ID(funcname) enum{ operation_ID = KC_OP_ID(funcname) };\
157 eKCOperationID GetID(){ return (eKCOperationID)operation_ID; };
159 #endif // __KC_OPERATION_ID__