~ubuntu-branches/debian/sid/openchange/sid

« back to all changes in this revision

Viewing changes to mapiproxy/libmapiserver/libmapiserver_oxcnotif.c

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-04-12 20:07:57 UTC
  • mfrom: (11 sid)
  • mto: This revision was merged to the branch mainline in revision 12.
  • Revision ID: package-import@ubuntu.com-20120412200757-k933d9trljmxj1l4
Tags: 1:1.0-4
* openchangeserver: Add dependency on openchangeproxy.
* Rebuild against newer version of Samba 4.
* Use dpkg-buildflags.
* Migrate to Git, update Vcs-Git header.
* Switch to debhelper 9.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
   \brief OXCNOTIF ROP Response size calculations
26
26
 */
27
27
 
 
28
 
28
29
#include "libmapiserver.h"
 
30
#include <util/debug.h>
29
31
 
30
32
/**
31
33
   \details Calculate RegisterNotification Rop size
36
38
{
37
39
        return SIZE_DFLT_MAPI_RESPONSE;
38
40
}
 
41
 
 
42
/**
 
43
   \details Calculate Notify Rop size
 
44
 
 
45
   \return Size of Notify response
 
46
 */
 
47
_PUBLIC_ uint16_t libmapiserver_RopNotify_size(struct EcDoRpc_MAPI_REPL *response)
 
48
{
 
49
        uint16_t size = SIZE_DFLT_ROPNOTIFY;
 
50
        union NotificationData *NotificationData;
 
51
 
 
52
        /* TODO: to be completed... */
 
53
 
 
54
        NotificationData = &response->u.mapi_Notify.NotificationData;
 
55
        printf("Looking for: 0x%x\n", response->u.mapi_Notify.NotificationType);
 
56
        switch (response->u.mapi_Notify.NotificationType) {
 
57
                /* Folders */
 
58
        case 0x3010: /* different forms of folder modifications */
 
59
                size += sizeof (uint32_t);
 
60
        case 0x1010:
 
61
        case 0x2010:
 
62
                size += sizeof (uint32_t);
 
63
        case 0x0010: /* folder modified */
 
64
                size += sizeof(uint64_t) + sizeof(uint16_t);
 
65
                if (NotificationData->FolderModifiedNotification_10.TagCount != 0xffff) {
 
66
                        size += sizeof(enum MAPITAGS) * NotificationData->FolderModifiedNotification_10.TagCount;
 
67
                }
 
68
                break;
 
69
 
 
70
        case 0x0004: /* folder created */
 
71
                break;
 
72
        case 0x0002: /* newmail */
 
73
        case 0x8002:
 
74
                size += sizeof (uint64_t) * 2 + sizeof (uint32_t) + sizeof (uint8_t);
 
75
                if (NotificationData->NewMailNotification.UnicodeFlag == false) {
 
76
                        size += strlen(NotificationData->NewMailNotification.MessageClass.lpszA);
 
77
                } else {
 
78
                        size += strlen(NotificationData->NewMailNotification.MessageClass.lpszW) * 2 + 2;
 
79
                }
 
80
                break;
 
81
        case 0x8004: /* message created */ 
 
82
        case 0x8010: /* message modified */
 
83
                size += sizeof(uint16_t);
 
84
                if (NotificationData->MessageCreatedNotification.TagCount != 0xffff) {
 
85
                        size += sizeof(enum MAPITAGS) * NotificationData->MessageCreatedNotification.TagCount;
 
86
                }
 
87
        case 0x8008: /* message deleted */
 
88
        case 0x0008: /* folder deleted */
 
89
                size += 2 * sizeof(uint64_t);
 
90
                break;
 
91
 
 
92
                /* Tables */
 
93
        case 0x0100: /* hierarchy table changed */
 
94
                size += sizeof(uint16_t); /* TableEventType */
 
95
                switch (NotificationData->HierarchyTableChange.TableEvent) {
 
96
                case TABLE_ROW_ADDED:
 
97
                        size += 2 * sizeof(uint64_t); /* FID and InsertAfterFID */
 
98
                        size += sizeof(uint16_t) + NotificationData->HierarchyTableChange.HierarchyTableChangeUnion.HierarchyRowAddedNotification.Columns.length; /* blob length */
 
99
                        break;
 
100
                case TABLE_ROW_DELETED:
 
101
                        size += sizeof(uint64_t); /* FID */
 
102
                        break;
 
103
                case TABLE_ROW_MODIFIED:
 
104
                        size += 2 * sizeof(uint64_t); /* FID and InsertAfterFID */
 
105
                        size += sizeof(uint16_t) + NotificationData->HierarchyTableChange.HierarchyTableChangeUnion.HierarchyRowModifiedNotification.Columns.length; /* blob length */
 
106
                        break;
 
107
                default: /* TABLE_CHANGED and TABLE_RESTRICT_DONE */
 
108
                        size += 0;
 
109
                }
 
110
                break;
 
111
        case 0x8100: /* contents table changed */
 
112
                size += sizeof(uint16_t); /* TableEventType */
 
113
                switch (NotificationData->ContentsTableChange.TableEvent) {
 
114
                case TABLE_ROW_ADDED:
 
115
                        size += 2 * (2 * sizeof(uint64_t) + sizeof(uint32_t)); /* FID, MID, Instance, InsertAfterFID, InsertAfterMID, InsertAfterInstance */
 
116
                        size += sizeof(uint16_t) + NotificationData->ContentsTableChange.ContentsTableChangeUnion.ContentsRowAddedNotification.Columns.length; /* blob length */
 
117
                        break;
 
118
                case TABLE_ROW_DELETED:
 
119
                        size += 2 * sizeof(uint64_t) + sizeof(uint32_t); /* FID, MID, Instance */
 
120
                        break;
 
121
                case TABLE_ROW_MODIFIED:
 
122
                        size += 2 * (2 * sizeof(uint64_t) + sizeof(uint32_t)); /* FID, MID, Instance, InsertAfterFID, InsertAfterMID, InsertAfterInstance */
 
123
                        size += sizeof(uint16_t) + NotificationData->ContentsTableChange.ContentsTableChangeUnion.ContentsRowModifiedNotification.Columns.length;
 
124
                        break;
 
125
                default: /* TABLE_CHANGED and TABLE_RESTRICT_DONE */
 
126
                        size += 0;
 
127
                }
 
128
                break;
 
129
        case 0xc100: /* search table changed */
 
130
                size += sizeof(uint16_t); /* TableEventType */
 
131
                switch (NotificationData->SearchTableChange.TableEvent) {
 
132
                case TABLE_ROW_ADDED:
 
133
                        size += 2 * (2 * sizeof(uint64_t) + sizeof(uint32_t)); /* FID, MID, Instance, InsertAfterFID, InsertAfterMID, InsertAfterInstance */
 
134
                        size += sizeof(uint16_t) + NotificationData->SearchTableChange.ContentsTableChangeUnion.ContentsRowAddedNotification.Columns.length; /* blob length */
 
135
                        break;
 
136
                case TABLE_ROW_DELETED:
 
137
                        size += 2 * sizeof(uint64_t) + sizeof(uint32_t); /* FID, MID, Instance */
 
138
                        break;
 
139
                case TABLE_ROW_MODIFIED:
 
140
                        size += 2 * (2 * sizeof(uint64_t) + sizeof(uint32_t)); /* FID, MID, Instance, InsertAfterFID, InsertAfterMID, InsertAfterInstance */
 
141
                        size += sizeof(uint16_t) + NotificationData->SearchTableChange.ContentsTableChangeUnion.ContentsRowModifiedNotification.Columns.length;
 
142
                        break;
 
143
                default: /* TABLE_CHANGED and TABLE_RESTRICT_DONE */
 
144
                        size += 0;
 
145
                }
 
146
                break;
 
147
 
 
148
        /* case 0x0002: */
 
149
        /* case 0x8002: */
 
150
        /*         size += sizeof(struct NewMailNotification); */
 
151
        /*         if (response->u.mapi_Notify.NewMailNotification.UnicodeFlag) { */
 
152
        /*                 size += strlen_m_ext(response->u.mapi_Notify.NewMailNotification.MessageClass.lpszW, CH_UTF8, CH_UTF16BE) * 2 + 2; */
 
153
        /*         } */
 
154
        /*         else { */
 
155
        /*                 size += strlen(response->u.mapi_Notify.NewMailNotification.MessageClass.lpszA) + 1; */
 
156
        /*         } */
 
157
        /*         break; */
 
158
        /* case 0x0020: */
 
159
        /* case 0x0040: */
 
160
        /*         size += sizeof(struct FolderMoveCopyNotification); */
 
161
        /*         break; */
 
162
        /* case 0x0080: */
 
163
        /*         size += sizeof(struct SearchCompleteNotification); */
 
164
        /*         break; */
 
165
        /* case 0x0100: */
 
166
        /*         size += sizeof(struct HierarchyTableChange); */
 
167
        /*         break; */
 
168
        /* case 0x0200: */
 
169
        /*         size += sizeof(struct IcsNotification); */
 
170
        /*         break; */
 
171
        /* case 0x1010: */
 
172
        /*         size += sizeof(struct FolderModifiedNotification_1010); */
 
173
        /*         break; */
 
174
        /* case 0x2010: */
 
175
        /*         size += sizeof(struct FolderModifiedNotification_2010); */
 
176
        /*         break; */
 
177
        /* case 0x3010: */
 
178
        /*         size += sizeof(struct FolderModifiedNotification_3010); */
 
179
        /*         break; */
 
180
        case 0x8020:
 
181
        case 0x8040:
 
182
                 size += sizeof(struct MessageMoveCopyNotification);
 
183
                 break; 
 
184
        /* case 0x8100: */
 
185
        /* case 0xc100: */
 
186
        /*         size += sizeof(struct ContentsTableChange); */
 
187
        /*         break; */
 
188
        /* case 0xc004: */
 
189
        /*         size += sizeof(struct SearchMessageCreatedNotification); */
 
190
        /*         break; */
 
191
        /* case 0xc008: */
 
192
        /*         size += sizeof(struct SearchMessageRemovedNotification); */
 
193
        /*         break; */
 
194
        /* case 0xc010: */
 
195
        /*         size += sizeof(struct SearchMessageModifiedNotification); */
 
196
        /*         break; */
 
197
        default:
 
198
                DEBUG(5, (__location__": unhandled size case %.4x, expect buffer errors soon\n", response->u.mapi_Notify.NotificationType));
 
199
        }
 
200
 
 
201
        return size;
 
202
}