~vcs-imports/openmapi/git-trunk

« back to all changes in this revision

Viewing changes to providers/NMapi.Provider.Styx/Session.cs

  • Committer: Michael Kukat
  • Date: 2010-05-11 08:29:11 UTC
  • Revision ID: git-v1:861c8321966c03511f5146777a067ddadc4846d7
separated 2 functions for better MAPI flexibility

Show diffs side-by-side

added added

removed removed

Lines of Context:
118
118
            return new MsgStore (StoreHandle);
119
119
        }
120
120
 
 
121
        public Table GetMsgStoresTable(int flags) {
 
122
            IntPtr TableHandle = IntPtr.Zero;
 
123
            Table table = null;
 
124
 
 
125
            int hr = CMapi_Session_GetMsgStoresTable (cobj, (uint) flags, out TableHandle);
 
126
 
 
127
            if(TableHandle != IntPtr.Zero) {
 
128
                table = new Table (TableHandle);
 
129
            }
 
130
            Transmogrify.CheckHResult (hr);
 
131
 
 
132
            return table;
 
133
        }
 
134
 
 
135
        public MsgStore OpenMsgStore(uint uiParam, byte[] entryId, NMapiGuid interFace, OpenStoreFlags flags) {
 
136
            using (MemContext MemCtx = new MemContext ()) {
 
137
                IntPtr storeHandle = IntPtr.Zero;
 
138
                IntPtr ifHandle = Transmogrify.GuidToPtr (interFace, MemCtx);
 
139
                MsgStore ret = null;
 
140
 
 
141
                int hr = CMapi_Session_OpenMsgStore (cobj, uiParam, (uint) entryId.Length, entryId, ifHandle, (uint) flags, out storeHandle);
 
142
                Transmogrify.CheckHResult (hr);
 
143
 
 
144
                if(storeHandle != IntPtr.Zero) {
 
145
                    ret = new MsgStore(storeHandle);
 
146
                }
 
147
 
 
148
                return ret;
 
149
            }
 
150
        }
 
151
 
121
152
        public IMsgStore OpenStore (OpenStoreFlags flags, string user, bool isPublic) {
122
153
 
123
154
            if (CMapi.IsNative == false) {
124
155
                return OpenStoreUMapi (isPublic);
125
156
            }
126
157
 
127
 
            IntPtr TableHandle;
128
 
            int hr = CMapi_Session_GetMsgStoresTable (cobj, 0, out TableHandle);
129
 
            Transmogrify.CheckHResult (hr);
130
 
 
131
 
            Table table = new Table (TableHandle);
 
158
            Table table = GetMsgStoresTable(0);
132
159
            try {
133
160
 
134
161
                PropertyTag[] cols = PropertyTag.ArrayFromIntegers (Property.EntryId,
154
181
                    throw new MapiNoSupportException ("Didn't found exactly one store, found " + RowSet.Count + " stores");
155
182
                }
156
183
 
157
 
                IntPtr storeHandle;
158
 
                hr = CMapi_Session_OpenMsgStore (cobj, 0, (uint) StoreId.Length, StoreId, IntPtr.Zero, (uint) flags, out storeHandle);
159
 
                Transmogrify.CheckHResult (hr);
160
 
                return new MsgStore (storeHandle);
161
 
 
 
184
                return OpenMsgStore(0, StoreId, null, flags);
162
185
            } catch (Exception e) {
163
186
                /* XXX WTF? */
164
187
                throw new NotSupportedException ("Error opening Message Store", e);