📄 pccapiutils.cs
字号:
//Filename : PCCAPIUtils.cs
//Part of : PCCAPI Example codes
//Description : Helper utilities, error management
//Version : 3.2
//
//This example is only to be used with PC Connectivity API version 3.2.
//Compability ("as is") with future versions is not quaranteed.
//
//Copyright (c) 2005-2007 Nokia Corporation.
//
//This material, including but not limited to documentation and any related
//computer programs, is protected by intellectual property rights of Nokia
//Corporation and/or its licensors.
//All rights are reserved. Reproducing, modifying, translating, or
//distributing any or all of this material requires the prior written consent
//of Nokia Corporation. Nokia Corporation retains the right to make changes
//to this material at any time without notice. A copyright license is hereby
//granted to download and print a copy of this material for personal use only.
//No other license to any other intellectual property rights is granted. The
//material is provided "as is" without warranty of any kind, either express or
//implied, including without limitation, any warranty of non-infringement,
//merchantability and fitness for a particular purpose. In no event shall
//Nokia Corporation be liable for any direct, indirect, special, incidental,
//or consequential loss or damages, including but not limited to, lost profits
//or revenue,loss of use, cost of substitute program, or loss of data or
//equipment arising out of the use or inability to use the material, even if
//Nokia Corporation has been advised of the likelihood of such damages occurring.
namespace PCCAPIUtils
{
using CONADefinitions;
using PCCSErrors;
class PCCAPIUtils
{
//===================================================================
// CONAError2String -- Returns error text for given CONA error code
//
//
//===================================================================
public static string CONAError2String(int errorCode)
{
string functionReturnValue = null;
functionReturnValue = "";
switch (errorCode)
{
case PCCSErrors.CONA_OK:
functionReturnValue = "CONA_OK: Succeeded.";
break;
case PCCSErrors.CONA_OK_UPDATED_MEMORY_VALUES:
functionReturnValue = "CONA_OK_UPDATED_MEMORY_VALUES: Everything OK, given data is updated because (free, used and total) memory values are changed!";
break;
case PCCSErrors.CONA_OK_UPDATED_MEMORY_AND_FILES:
functionReturnValue = "CONA_OK_UPDATED_MEMORY_AND_FILES: Everything OK, given data is updated because files and memory values are changed!";
break;
case PCCSErrors.CONA_OK_UPDATED:
functionReturnValue = "CONA_OK_UPDATED: Everything OK, given data is updated, unknown reason.";
break;
case PCCSErrors.CONA_OK_BUT_USER_ACTION_NEEDED:
functionReturnValue = "CONA_OK_BUT_USER_ACTION_NEEDED: Operation needs some user action on Device";
break;
case PCCSErrors.CONA_WAIT_CONNECTION_IS_BUSY:
functionReturnValue = "CONA_WAIT_CONNECTION_IS_BUSY: Operation started ok but other application has reserved the connection";
break;
// Common error codes:
case PCCSErrors.ECONA_INIT_FAILED:
functionReturnValue = "ECONA_INIT_FAILED: DLL initialization failed.";
break;
case PCCSErrors.ECONA_INIT_FAILED_COM_INTERFACE:
functionReturnValue = "ECONA_INIT_FAILED_COM_INTERFACE: Failed to get connection to system.";
break;
case PCCSErrors.ECONA_NOT_INITIALIZED:
functionReturnValue = "ECONA_NOT_INITIALIZED: API is not initialized.";
break;
case PCCSErrors.ECONA_UNSUPPORTED_API_VERSION:
functionReturnValue = "ECONA_UNSUPPORTED_API_VERSION: API version not supported.";
break;
case PCCSErrors.ECONA_NOT_SUPPORTED_MANUFACTURER:
functionReturnValue = "ECONA_NOT_SUPPORTED_MANUFACTURER: Manufacturer is not supported.";
break;
case PCCSErrors.ECONA_UNKNOWN_ERROR:
functionReturnValue = "ECONA_UNKNOWN_ERROR: Failed, unknown error.";
break;
case PCCSErrors.ECONA_UNKNOWN_ERROR_DEVICE:
functionReturnValue = "ECONA_UNKNOWN_ERROR_DEVICE: Failed, unknown error from device.";
break;
case PCCSErrors.ECONA_INVALID_POINTER:
functionReturnValue = "ECONA_INVALID_POINTER: Required pointer is invalid.";
break;
case PCCSErrors.ECONA_INVALID_PARAMETER:
functionReturnValue = "ECONA_INVALID_PARAMETER: Invalid parameter value.";
break;
case PCCSErrors.ECONA_INVALID_HANDLE:
functionReturnValue = "ECONA_INVALID_HANDLE: Invalid handle.";
break;
case PCCSErrors.ECONA_NOT_ENOUGH_MEMORY:
functionReturnValue = "ECONA_NOT_ENOUGH_MEMORY: Memory allocation failed in PC.";
break;
case PCCSErrors.ECONA_WRONG_THREAD:
functionReturnValue = "ECONA_WRONG_THREAD: Failed, called interface was marshalled for a different thread.";
break;
case PCCSErrors.ECONA_REGISTER_ALREADY_DONE:
functionReturnValue = "ECONA_REGISTER_ALREADY_DONE: Failed, notification interface is already registered.";
break;
case PCCSErrors.ECONA_CANCELLED:
functionReturnValue = "ECONA_CANCELLED: Operation cancelled by ConnectivityAPI-User.";
break;
case PCCSErrors.ECONA_NOTHING_TO_CANCEL:
functionReturnValue = "ECONA_NOTHING_TO_CANCEL: No running functions.";
break;
case PCCSErrors.ECONA_FAILED_TIMEOUT:
functionReturnValue = "ECONA_FAILED_TIMEOUT: Operation failed because of timeout.";
break;
case PCCSErrors.ECONA_NOT_SUPPORTED_DEVICE:
functionReturnValue = "ECONA_NOT_SUPPORTED_DEVICE: Device does not support operation.";
break;
case PCCSErrors.ECONA_NOT_SUPPORTED_PC:
functionReturnValue = "ECONA_NOT_SUPPORTED_PC: Connectivity API does not support operation (not implemented).";
break;
case PCCSErrors.ECONA_NOT_FOUND:
functionReturnValue = "ECONA_NOT_FOUND: Item was not found";
break;
case PCCSErrors.ECONA_FAILED:
functionReturnValue = "ECONA_FAILED: The called operation failed.";
break;
case PCCSErrors.ECONA_API_NOT_FOUND:
functionReturnValue = "ECONA_API_NOT_FOUND: Needed API module was not found from the system";
break;
case PCCSErrors.ECONA_API_FUNCTION_NOT_FOUND:
functionReturnValue = "ECONA_API_FUNCTION_NOT_FOUND: Called API function was not found from the loaded API module";
break;
// Device manager and device connection related errors:
case PCCSErrors.ECONA_DEVICE_NOT_FOUND:
functionReturnValue = "ECONA_DEVICE_NOT_FOUND: Given phone is not connected (refresh device list).";
break;
case PCCSErrors.ECONA_NO_CONNECTION_VIA_MEDIA:
functionReturnValue = "ECONA_NO_CONNECTION_VIA_MEDIA: Phone is connected but not via given media.";
break;
case PCCSErrors.ECONA_NO_CONNECTION_VIA_DEVID:
functionReturnValue = "ECONA_NO_CONNECTION_VIA_DEVID: Phone is not connected with given DevID.";
break;
case PCCSErrors.ECONA_INVALID_CONNECTION_TYPE:
functionReturnValue = "ECONA_INVALID_CONNECTION_TYPE: Connection type was invalid.";
break;
case PCCSErrors.ECONA_NOT_SUPPORTED_CONNECTION_TYPE:
functionReturnValue = "ECONA_NOT_SUPPORTED_CONNECTION_TYPE: Device does not support connection type.";
break;
case PCCSErrors.ECONA_CONNECTION_BUSY:
functionReturnValue = "ECONA_CONNECTION_BUSY: Other application has reserved connection.";
break;
case PCCSErrors.ECONA_CONNECTION_LOST:
functionReturnValue = "ECONA_CONNECTION_LOST: Connection lost to device.";
break;
case PCCSErrors.ECONA_CONNECTION_REMOVED:
functionReturnValue = "ECONA_CONNECTION_REMOVED: Connection removed, other application has reserved connection.";
break;
case PCCSErrors.ECONA_CONNECTION_FAILED:
functionReturnValue = "ECONA_CONNECTION_FAILED: Connection failed, unknown reason.";
break;
case PCCSErrors.ECONA_SUSPEND:
functionReturnValue = "ECONA_SUSPEND: Connection removed, PC goes to standby state.";
break;
case PCCSErrors.ECONA_NAME_ALREADY_EXISTS:
functionReturnValue = "ECONA_NAME_ALREADY_EXISTS: Friendly name already exists.";
break;
case PCCSErrors.ECONA_MEDIA_IS_NOT_WORKING:
functionReturnValue = "ECONA_MEDIA_IS_NOT_WORKING: Target media is active but it is not working (e.g. BT hardware stopped or removed).";
break;
case PCCSErrors.ECONA_CACHE_IS_NOT_AVAILABLE:
functionReturnValue = "ECONA_CACHE_IS_NOT_AVAILABLE: Cache is not available (CONASearchDevices).";
break;
case PCCSErrors.ECONA_MEDIA_IS_NOT_ACTIVE:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -