2121import com .sun .jna .platform .mac .CoreFoundation ;
2222import com .sun .jna .ptr .IntByReference ;
2323import com .sun .jna .ptr .PointerByReference ;
24- import qz .printer .status .Cups ;
2524
2625/**
2726 * The JNA library interface to access the Security library under MacOS.
@@ -32,43 +31,45 @@ public interface Security extends Library {
3231
3332 Security INSTANCE = Native .load ("Security" , Security .class );
3433
35- enum SecBase {
36- errSecSuccess ( 0 , "No error." ),
37- errSecUnimplemented ( -4 , "Function or operation not implemented." ),
38- errSecIO ( -36 , "I/O error (bummers)" ),
39- errSecOpWr ( -49 , "file already open with with write permission" ),
40- errSecParam ( -50 , "One or more parameters passed to a function where not valid." ),
41- errSecAllocate ( -108 , "Failed to allocate memory." ),
42- errSecUserCanceled ( -128 , "User canceled the operation." ),
43- errSecBadReq ( -909 , "Bad parameter or invalid state for operation." ),
44- errSecInternalComponent ( -2070 ,"Internal component failure" ),
45- errSecNotAvailable ( -25291 , "No keychain is available. You may need to restart your computer." ),
46- errSecDuplicateItem ( -25299 , "The specified item already exists in the keychain." ),
47- errSecItemNotFound ( -25300 , "The specified item could not be found in the keychain." ),
48- errSecInteractionNotAllowed ( -25308 , "User interaction is not allowed." ),
49- errSecDecode ( -26275 , "Unable to decode the provided data." ),
50- errSecAuthFailed ( -25293 , "The user name or passphrase you entered is not correct." ),
51- UNKNOWN (-99999 , "Code not mapped" );
34+ enum Status {
35+ SUCCESS ( "errSecSuccess" , 0 , "No error." ),
36+ UNIMPLEMENTED ( "errSecUnimplemented" , -4 , "Function or operation not implemented." ),
37+ IO ( "errSecIO" , -36 , "I/O error (bummers)" ),
38+ OPWR ( "errSecOpWr" , -49 , "File already open with write permission" ),
39+ PARAM ( "errSecParam" , -50 , "One or more parameters passed to a function where not valid." ),
40+ ALLOCATE ( "errSecAllocate" , -108 , "Failed to allocate memory." ),
41+ USER_CANCELED ( "errSecUserCanceled" , -128 , "User canceled the operation." ),
42+ BAD_REQ ( "errSecBadReq" , -909 , "Bad parameter or invalid state for operation." ),
43+ INTERNAL_COMPONENT ( "errSecInternalComponent" , -2070 ,"Internal component failure" ),
44+ NOT_AVAILABLE ( "errSecNotAvailable" , -25291 , "No keychain is available. You may need to restart your computer." ),
45+ DUPLICATE_ITEM ( "errSecDuplicateItem" , -25299 , "The specified item already exists in the keychain." ),
46+ ITEM_NOT_FOUND ( "errSecItemNotFound" , -25300 , "The specified item could not be found in the keychain." ),
47+ INTERACTION_NOT_ALLOWED ( "errSecInteractionNotAllowed" , -25308 , "User interaction is not allowed." ),
48+ DECODE ( "errSecDecode" , -26275 , "Unable to decode the provided data." ),
49+ AUTH_FAILED ( "errSecAuthFailed" , -25293 , "The user name or passphrase you entered is not correct." ),
50+ UNKNOWN ("unknown" , -99999 , "Code not mapped" );
5251
5352 int code ;
53+ String name ;
5454 String message ;
55- SecBase (int code , String message ) {
55+ Status (String name , int code , String message ) {
56+ this .name = name ;
5657 this .code = code ;
5758 this .message = message ;
5859 }
5960
60- public static SecBase parse (int code ) {
61- for (SecBase secBase : SecBase .values ()) {
62- if (code == secBase .code ) {
63- return secBase ;
61+ public static Status parse (int code ) {
62+ for (Status status : Status .values ()) {
63+ if (code == status .code ) {
64+ return status ;
6465 }
6566 }
6667 return UNKNOWN ;
6768 }
6869
6970 @ Override
7071 public String toString () {
71- return String .format ("(%d) [%s] %s" , this .code , this . name () , this .message );
72+ return String .format ("(%d) [%s] %s" , this .code , name , this .message );
7273 }
7374 }
7475
0 commit comments