📄 pgpdialogoptions.c
字号:
break;
}
default:
{
err = kPGPError_UnknownRequest;
break;
}
}
return( err );
}
PGPOptionListRef
PGPOUIRecipientGroups(
PGPContextRef context,
PGPGroupSetRef groupSet)
{
PGPOptionListRef optionList;
PGPOptionValue value;
pgpValidateOptionContext( context );
pgpValidateOptionParam( PGPGroupSetRefIsValid( groupSet ) );
if( IsntPGPError( PGPCopyGroupSet( groupSet, &value.asGroupSetRef ) ) )
{
optionList = pgpCreateStandardValueOptionList( context,
kPGPOptionType_RecipientGroups,
&value, sizeof( groupSet ),
GroupSetOptionHandlerProc );
}
else
{
optionList = kPGPOutOfMemoryOptionListRef;
}
return( optionList );
}
PGPOptionListRef
PGPOUIEnforceAdditionalRecipientRequests(
PGPContextRef context,
PGPAdditionalRecipientRequestEnforcement enforcement,
PGPBoolean alwaysDisplayDialogWithARRs)
{
PGPOptionListRef optionList;
PGPOptionValue value;
pgpValidateOptionContext( context );
value.asARRParams.enforcement = enforcement;
value.asARRParams.displayDialog = ( alwaysDisplayDialogWithARRs != 0 );
optionList = pgpCreateStandardValueOptionList( context,
kPGPOptionType_ARREnforcement,
&value, sizeof( PGPOUIARRParamsDesc ), NULL );
return( optionList );
}
static PGPError
KeyServerOptionHandlerProc(
PGPContextRef context,
PGPOptionHandlerOperation operation,
PGPOptionType type,
PGPOptionValue inputValue,
PGPSize inputValueSize,
PGPOptionValue *outputValue,
PGPSize *outputValueSize)
{
PGPError err = kPGPError_NoErr;
(void) context;
(void) inputValueSize;
(void) outputValueSize;
(void) outputValue;
switch( operation )
{
case kPGPOptionHandler_FreeDataOperation:
{
switch( type )
{
case kPGPOptionType_KeyServerSearchFilter:
PGPFreeFilter( inputValue.asFilterRef );
break;
case kPGPOptionType_KeyServerSearchKeySet:
PGPFreeKeySet( inputValue.asKeySetRef );
break;
default:
break;
}
break;
}
case kPGPOptionHandler_CopyDataOperation:
{
switch( type )
{
case kPGPOptionType_KeyServerSearchFilter:
PGPIncFilterRefCount( inputValue.asFilterRef );
break;
case kPGPOptionType_KeyServerSearchKeySet:
PGPIncKeySetRefCount( inputValue.asKeySetRef );
break;
default:
break;
}
}
default:
{
err = kPGPError_UnknownRequest;
break;
}
}
return( err );
}
PGPOptionListRef
PGPOUIKeyServerSearchFilter(
PGPContextRef context,
PGPFilterRef filter)
{
PGPOptionListRef optionList;
PGPOptionValue value;
pgpValidateOptionContext( context );
pgpValidateOptionParam( PGPFilterRefIsValid( filter ) );
value.asFilterRef = filter;
PGPIncFilterRefCount( filter );
optionList = pgpCreateStandardValueOptionList( context,
kPGPOptionType_KeyServerSearchFilter,
&value, sizeof( filter ),
KeyServerOptionHandlerProc );
return( optionList );
}
PGPOptionListRef
PGPOUIKeyServerSearchKeySet(
PGPContextRef context,
PGPKeySetRef keySet)
{
PGPOptionListRef optionList;
PGPOptionValue value;
pgpValidateOptionContext( context );
pgpValidateOptionParam( PGPKeySetRefIsValid( keySet ) );
value.asKeySetRef = keySet;
PGPIncKeySetRefCount( keySet );
optionList = pgpCreateStandardValueOptionList( context,
kPGPOptionType_KeyServerSearchKeySet,
&value, sizeof( keySet ),
KeyServerOptionHandlerProc );
return( optionList );
}
PGPOptionListRef
PGPOUIKeyServerSearchKeyIDList(
PGPContextRef context,
PGPUInt32 keyIDCount,
const PGPKeyID keyIDList[])
{
PGPOptionListRef optionList;
pgpValidateOptionContext( context );
pgpValidateOptionParam( IsntNull( keyIDList ) );
pgpValidateOptionParam( keyIDCount > 0 );
optionList = pgpCreateBufferOptionList( context,
kPGPOptionType_KeyServerSearchKeyIDList,
keyIDList, keyIDCount * sizeof( keyIDList[0] ) );
return( optionList );
}
PGPOptionListRef
PGPOUIKeyServerSearchKey(
PGPContextRef context,
PGPKeyRef key)
{
PGPOptionListRef optionList;
PGPOptionValue value;
pgpValidateOptionContext( context );
pgpValidateOptionParam( PGPKeyRefIsValid( key ) );
value.asKeyRef = key;
optionList = pgpCreateStandardValueOptionList( context,
kPGPOptionType_KeyServerSearchKey,
&value, sizeof( key ), NULL );
return( optionList );
}
static void
FreePGPOUIKeyServerParamsDesc(
PGPContextRef context,
PGPOUIKeyServerParamsDesc *desc)
{
pgpAssertAddrValid( desc, PGPOUIKeyServerParamsDesc );
if( IsntNull( desc->serverList ) )
{
PGPUInt32 specIndex;
for( specIndex = 0; specIndex < desc->serverCount; specIndex++)
{
PGPKeyServerSpec *spec = &desc->serverList[specIndex];
if( IsntNull( spec->serverName ) )
pgpContextMemFree( context, (char *) spec->serverName );
if( PGPKeyServerRefIsValid( spec->server ) )
PGPFreeKeyServer( spec->server );
}
PGPFreeData( (PGPKeyServerSpec *) desc->serverList );
desc->serverList = NULL;
}
PGPFreeData( desc );
}
static PGPError
CopyPGPOUIKeyServerParamsDesc(
PGPContextRef context,
const PGPOUIKeyServerParamsDesc *srcDesc,
PGPOUIKeyServerParamsDesc **destDesc)
{
PGPError err = kPGPError_NoErr;
PGPOUIKeyServerParamsDesc *outDesc;
pgpAssertAddrValid( srcDesc, PGPOUIKeyServerParamsDesc );
pgpAssertAddrValid( destDesc, PGPOUIKeyServerParamsDesc * );
*destDesc = NULL;
outDesc = (PGPOUIKeyServerParamsDesc *) PGPNewData(
PGPGetContextMemoryMgr( context ),
sizeof( *outDesc ), kPGPMemoryMgrFlags_Clear );
if( IsntNull( outDesc ) )
{
PGPSize dataSize;
pgpAssertAddrValid( srcDesc->serverList, PGPKeyServerSpec );
*outDesc = *srcDesc;
dataSize = srcDesc->serverCount * sizeof( PGPKeyServerSpec );
outDesc->serverList = (PGPKeyServerSpec *) PGPNewData(
PGPGetContextMemoryMgr( context ),
dataSize, 0 );
if( IsntNull( outDesc->serverList ) )
{
PGPUInt32 specIndex;
pgpCopyMemory( srcDesc->serverList,
(PGPKeyServerSpec *) outDesc->serverList, dataSize );
/* Need to copy server names and domains */
for(specIndex = 0; specIndex < srcDesc->serverCount; specIndex++)
{
PGPKeyServerSpec *spec = &outDesc->serverList[specIndex];
spec->serverName = NULL;
if( PGPKeyServerRefIsValid( spec->server ) )
{
PGPIncKeyServerRefCount( spec->server );
}
}
for(specIndex = 0; specIndex < srcDesc->serverCount; specIndex++)
{
PGPKeyServerSpec *srcSpec;
PGPKeyServerSpec *destSpec;
srcSpec = &srcDesc->serverList[specIndex];
destSpec = &outDesc->serverList[specIndex];
if( IsntNull( srcSpec->serverName ) )
{
destSpec->serverName = pgpAllocCString( context,
srcSpec->serverName );
if( IsNull( destSpec->serverName ) )
err = kPGPError_OutOfMemory;
}
if( IsPGPError( err ) )
break;
}
}
else
{
err = kPGPError_OutOfMemory;
}
if( IsPGPError( err ) )
{
FreePGPOUIKeyServerParamsDesc( context, outDesc );
outDesc = NULL;
}
}
else
{
err = kPGPError_OutOfMemory;
}
*destDesc = outDesc;
return( err );
}
static PGPError
KeyServerParamsOptionHandlerProc(
PGPContextRef context,
PGPOptionHandlerOperation operation,
PGPOptionType type,
PGPOptionValue inputValue,
PGPSize inputValueSize,
PGPOptionValue *outputValue,
PGPSize *outputValueSize)
{
PGPError err = kPGPError_NoErr;
PGPOUIKeyServerParamsDesc *inputDesc;
pgpAssert( inputValueSize == sizeof( *inputDesc ) );
(void) type;
(void) inputValueSize;
inputDesc = (PGPOUIKeyServerParamsDesc *) inputValue.asPtr;
pgpAssertAddrValid( inputDesc, PGPOUIKeyServerParamsDesc );
switch( operation )
{
case kPGPOptionHandler_FreeDataOperation:
{
FreePGPOUIKeyServerParamsDesc( context, inputDesc );
break;
}
case kPGPOptionHandler_CopyDataOperation:
{
PGPOUIKeyServerParamsDesc *outputDesc;
pgpAssertAddrValid( outputValue, PGPOptionValue );
pgpAssertAddrValid( outputValueSize, PGPSize );
err = CopyPGPOUIKeyServerParamsDesc( context, inputDesc,
&outputDesc );
if( IsntPGPError( err ) )
{
outputValue->asPtr = outputDesc;
*outputValueSize = sizeof( *outputDesc );
}
break;
}
default:
{
err = kPGPError_UnknownRequest;
break;
}
}
return( err );
}
PGPOptionListRef
PGPOUIKeyServerUpdateParams(
PGPContextRef context,
PGPUInt32 serverCount,
const PGPKeyServerSpec serverList[],
PGPtlsContextRef tlsContext,
PGPBoolean searchBeforeDisplay,
PGPKeySetRef *foundKeys,
PGPOptionListRef firstOption,
...)
{
PGPOptionListRef optionList;
va_list args;
if( IsntNull( foundKeys ) )
*foundKeys = kInvalidPGPKeySetRef;
pgpAssert( IsntNull( foundKeys ) );
pgpAssert( PGPContextRefIsValid( context ) );
pgpAssert( IsntNull( serverList ) );
pgpAssert( serverCount > 0 );
if( PGPContextRefIsValid( context ) &&
IsntNull( foundKeys ) &&
IsntNull( serverList ) &&
serverCount > 0 )
{
PGPOptionListRef subOptions;
PGPOUIKeyServerParamsDesc descriptor;
PGPOUIKeyServerParamsDesc *allocatedDesc;
va_start( args, firstOption );
subOptions = pgpBuildOptionListArgs( context,
FALSE, firstOption, args );
va_end( args );
pgpClearMemory( &descriptor, sizeof( descriptor ) );
descriptor.serverList = (PGPKeyServerSpec *) serverList;
descriptor.serverCount = serverCount;
descriptor.tlsContext = tlsContext;
descriptor.searchBeforeDisplay = searchBeforeDisplay;
descriptor.foundKeys = foundKeys;
if( IsntPGPError( CopyPGPOUIKeyServerParamsDesc( context, &descriptor,
&allocatedDesc ) ) )
{
PGPOptionValue value;
value.asPtr = allocatedDesc;
optionList = pgpCreateCustomValueOptionList( context,
kPGPOptionType_KeyServerUpdateParams,
kPGPOptionFlag_Default, &value,
sizeof( *allocatedDesc ), subOptions,
KeyServerParamsOptionHandlerProc );
}
else
{
PGPFreeOptionList( subOptions );
optionList = kPGPOutOfMemoryOptionListRef;
}
}
else
{
va_start( args, firstOption );
pgpFreeVarArgOptionList( firstOption, args);
va_end( args );
optionList = kPGPBadParamsOptionListRef;
}
return( optionList );
}
PGPOptionListRef
PGPOUIRecipientList(
PGPContextRef context,
PGPUInt32 *recipientCount,
PGPRecipientSpec **recipientList)
{
PGPOUIRecipientListDesc desc;
PGPOptionListRef optionList;
pgpValidateOptionContext( context );
pgpValidateOptionParam( IsntNull( recipientCount ) );
pgpValidateOptionParam( IsntNull( recipientList ) );
desc.recipientCount = recipientCount;
desc.recipientList = recipientList;
optionList = pgpCreateBufferOptionList( context,
kPGPOptionType_RecipientList,
&desc, sizeof( desc ) );
return( optionList );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -