kcodes.cpp 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2005 - 2016 Zarafa and its licensors
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU Affero General Public License, version 3,
  6. * as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU Affero General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU Affero General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. *
  16. */
  17. #include <kopano/platform.h>
  18. #include <mapicode.h>
  19. #include <kopano/kcodes.h>
  20. #include <kopano/mapiext.h>
  21. namespace KC {
  22. /*
  23. * Some helper functions to convert the SOAP-style objects
  24. * to MAPI-style structs and vice-versa
  25. */
  26. HRESULT kcerr_to_mapierr(ECRESULT ecResult, HRESULT hrDefault)
  27. {
  28. switch(ecResult) {
  29. case KCERR_NONE: return S_OK;
  30. // case KCERR_UNKNOWN: return MAPI_E_UNKNOWN; // No MAPI error?
  31. case KCERR_NOT_FOUND: return MAPI_E_NOT_FOUND;
  32. case KCERR_NO_ACCESS: return MAPI_E_NO_ACCESS;
  33. case KCERR_NETWORK_ERROR: return MAPI_E_NETWORK_ERROR;
  34. case KCERR_SERVER_NOT_RESPONDING: return MAPI_E_NETWORK_ERROR;
  35. case KCERR_INVALID_TYPE: return MAPI_E_INVALID_TYPE;
  36. case KCERR_DATABASE_ERROR: return MAPI_E_DISK_ERROR;
  37. case KCERR_COLLISION: return MAPI_E_COLLISION;
  38. case KCERR_LOGON_FAILED: return MAPI_E_LOGON_FAILED;
  39. case KCERR_HAS_MESSAGES: return MAPI_E_HAS_MESSAGES;
  40. case KCERR_HAS_FOLDERS: return MAPI_E_HAS_FOLDERS;
  41. // case KCERR_HAS_RECIPIENTS: return KCERR_HAS_RECIPIENTS; // No MAPI error?
  42. // case KCERR_HAS_ATTACHMENTS: return KCERR_HAS_ATTACHMENTS; // No MAPI error?
  43. case KCERR_NOT_ENOUGH_MEMORY: return MAPI_E_NOT_ENOUGH_MEMORY;
  44. case KCERR_TOO_COMPLEX: return MAPI_E_TOO_COMPLEX;
  45. case KCERR_END_OF_SESSION: return MAPI_E_END_OF_SESSION;
  46. case KCERR_UNABLE_TO_ABORT: return MAPI_E_UNABLE_TO_ABORT;
  47. case KCWARN_CALL_KEEPALIVE: return KCWARN_CALL_KEEPALIVE; // Internal information
  48. case KCERR_NOT_IN_QUEUE: return MAPI_E_NOT_IN_QUEUE;
  49. case KCERR_INVALID_PARAMETER: return MAPI_E_INVALID_PARAMETER;
  50. case KCWARN_PARTIAL_COMPLETION: return MAPI_W_PARTIAL_COMPLETION;
  51. case KCERR_INVALID_ENTRYID: return MAPI_E_INVALID_ENTRYID;
  52. case KCERR_TOO_BIG: return MAPI_E_TOO_BIG;
  53. case KCWARN_POSITION_CHANGED: return MAPI_W_POSITION_CHANGED;
  54. case KCERR_FOLDER_CYCLE: return MAPI_E_FOLDER_CYCLE;
  55. case KCERR_STORE_FULL: return MAPI_E_STORE_FULL;
  56. case KCERR_NOT_INITIALIZED: return MAPI_E_NOT_INITIALIZED;
  57. case KCERR_CALL_FAILED: return MAPI_E_CALL_FAILED;
  58. case KCERR_TIMEOUT: return MAPI_E_TIMEOUT;
  59. case KCERR_INVALID_BOOKMARK: return MAPI_E_INVALID_BOOKMARK;
  60. case KCERR_UNABLE_TO_COMPLETE: return MAPI_E_UNABLE_TO_COMPLETE;
  61. case KCERR_INVALID_VERSION: return MAPI_E_VERSION;
  62. case KCERR_OBJECT_DELETED: return MAPI_E_OBJECT_DELETED;
  63. case KCERR_USER_CANCEL: return MAPI_E_USER_CANCEL;
  64. case KCERR_UNKNOWN_FLAGS: return MAPI_E_UNKNOWN_FLAGS;
  65. case KCERR_SUBMITTED: return MAPI_E_SUBMITTED;
  66. case KCERR_NO_SUPPORT:
  67. case KCERR_NOT_IMPLEMENTED:
  68. return MAPI_E_NO_SUPPORT;
  69. default: return hrDefault;
  70. }
  71. }
  72. } /* namespace */