aboutsummaryrefslogtreecommitdiffstats
path: root/src/native/addrbook/msoutlook/MsOutlookMAPIHResultException.cpp
blob: 115e6f0c861e3346abaa7493da4d4edaa6739103 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "MsOutlookMAPIHResultException.h"

void
MsOutlookMAPIHResultException_throwNew
    (JNIEnv *jniEnv, HRESULT hResult, LPCTSTR file, ULONG line)
{
    jclass clazz;

    clazz
        = jniEnv->FindClass(
                "net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookMAPIHResultException");
    if (clazz)
    {
        LPCTSTR message;

        switch (hResult)
        {
        case MAPI_E_LOGON_FAILED:
            message = _T("MAPI_E_LOGON_FAILED");
            break;
        case MAPI_E_NO_ACCESS:
            message = _T("MAPI_E_NO_ACCESS");
            break;
        case MAPI_E_NOT_ENOUGH_MEMORY:
            message = _T("MAPI_E_NOT_ENOUGH_MEMORY");
            break;
        case MAPI_E_NOT_FOUND:
            message = _T("MAPI_E_NOT_FOUND");
            break;
        case MAPI_E_NOT_INITIALIZED:
            message = _T("MAPI_E_NOT_INITIALIZED");
            break;
        case MAPI_E_TIMEOUT:
            message = _T("MAPI_E_TIMEOUT");
            break;
        case MAPI_E_UNKNOWN_ENTRYID:
            message = _T("MAPI_E_UNKNOWN_ENTRYID");
            break;
        case MAPI_E_USER_CANCEL:
            message = _T("MAPI_E_USER_CANCEL");
            break;
        case MAPI_W_ERRORS_RETURNED:
            message = _T("MAPI_W_ERRORS_RETURNED");
            break;
        case S_OK:
            message = _T("S_OK");
            break;
        default:
            message = NULL;
            break;
        }

        if (message)
        {
            jmethodID methodID;

            methodID
                = jniEnv->GetMethodID(
                        clazz,
                        "<init>",
                        "(JLjava/lang/String;)V");
            if (methodID)
            {
                jobject t;

                t = jniEnv->NewObject(clazz, methodID, hResult, message);
                if (t)
                    jniEnv->Throw((jthrowable) t);
                return;
            }
        }

        {
            jmethodID methodID;

            methodID = jniEnv->GetMethodID(clazz, "<init>", "(J)V");
            if (methodID)
            {
                jobject t;

                t = jniEnv->NewObject(clazz, methodID, hResult);
                if (t)
                    jniEnv->Throw((jthrowable) t);
                return;
            }
        }

        jniEnv->ThrowNew(clazz, message);
    }
}