public MsgHTTP(IMsgStore store_, bool isHost = false) { if (isHost) { PortClient = PortHost; } store = store_; /////////////////////////////////////////////////////////////////////// // HTTP LISTENER listener = new HttpListener(); TcpListener lis = new TcpListener(IPAddress.Loopback, PortClient); lis.Start(); PortClient = ((IPEndPoint)lis.LocalEndpoint).Port; lis.Stop(); listener.Prefixes.Add("http://*:" + PortClient.ToString() + "/"); listener.Start(); new Thread(() => { while (true) { HttpListenerContext ctx = listener.GetContext(); ThreadPool.QueueUserWorkItem((_) => ProcessRequest(ctx)); } }).Start(); }
/// <summary> /// Initializes a new instance of the MsgStore class. /// </summary> /// <param name="msgStore">IMsgStore object</param> /// <param name="entryID">Entry identification of IMsgStore object</param> public MessageStore(MAPISession session, IMsgStore msgStore, EntryID entryID, string name) { ulConnection_ = 0; Session = session; mapiObj_ = msgStore; Id_ = entryID; Name = name; }
/// <summary> /// Dispose Msgstore object /// </summary> public void Dispose() { UnRegisteEvents(); Session = null; if (mapiObj_ != null) { Marshal.ReleaseComObject(mapiObj_); mapiObj_ = null; } }
public MsgConnect(ILog _log, IMsgStore _msg) { log = _log; msg = _msg; _lock = new object(); conSocket = new Dictionary <long, IWebSocketConnection>() { }; conName = new List <Tuple <long, string> >(); }
public MsgListener(IMsgStore store_, bool isHost = false) { if (isHost) { PortClient = PortHost; } store = store_; /////////////////////////////////////////////////////////////////////// // HTTP LISTENER listener = new HttpListener(); TcpListener lis = new TcpListener(IPAddress.Loopback, PortClient); lis.Start(); PortClient = ((IPEndPoint)lis.LocalEndpoint).Port; lis.Stop(); listener.Prefixes.Add("http://*:" + PortClient.ToString() + "/"); listener.Start(); listener.BeginGetContext(ProcessRequest, listener); }
private void ShowStoreInTree(IMsgStore store) { //Add the stuff in this store to the tree MapiStoreNode storeNode = new MapiStoreNode(store); treeFolders.Nodes.Add(storeNode); //Get the ID of the root folder ENTRYID rootIpmFolder = MapiUtils.GetEntryIdProperty(store, Tags.PR_IPM_SUBTREE_ENTRYID); MAPI33.MAPI.TYPE objType; IUnknown unk; Error hr = store.OpenEntry(rootIpmFolder, Guid.Empty, 0, out objType, out unk); if (hr != Error.Success) { throw new MapiException(hr); } using (unk) { IMAPIFolder folder = (IMAPIFolder)unk; using (folder) { ShowFolderInTree(storeNode, folder); } } }
public MAPIAdviseSink(IMsgStore store, EEventMask eventMask, IMAPISession owner) { this.store = store; IntPtr ptr = IntPtr.Zero; this.callbackHandler = OnNotifyCallback; HRESULT hr = MAPIlibAdvise(store.Ptr, eventMask, this.callbackHandler, ref ptr); if (hr != HRESULT.S_OK) throw new Exception("MAPIlibAdvise failed: " + hr.ToString()); this.adviserPtr = ptr; this.owner = owner; }
/// <summary> /// Opens a message store. /// </summary> /// <param name="storeName">store name</param> /// <returns>true, if the message store was successfully opened; otherwise, failed.</returns> public bool OpenMessageStore(string storeName) { bool bResult = false; try { if (Content != null) { Content.SeekRow(BookMark.BEGINNING, 0); if (Content.SetColumns(new PropTags[] { PropTags.PR_DISPLAY_NAME, PropTags.PR_ENTRYID, PropTags.PR_DEFAULT_STORE })) { SRow[] sRows; while (Content.QueryRows(1, out sRows)) { if (sRows.Length != 1) { break; } if (string.IsNullOrEmpty(storeName)) { if (sRows[0].propVals[2].AsBool) { bResult = true; } } else if (sRows[0].propVals[0].AsString.IndexOf(storeName) > -1) { bResult = true; } if (bResult) { break; } } if (bResult) { if (CurrentStore != null) { CurrentStore.Dispose(); CurrentStore = null; } SBinary entryId = SBinary.SBinaryCreate(sRows[0].propVals[1].AsBinary); storeName = sRows[0].propVals[0].AsString; IntPtr pStore = IntPtr.Zero; if (session_.OpenMsgStore(0, entryId.cb, entryId.lpb, IntPtr.Zero, (uint)MAPIFlag.BEST_ACCESS, out pStore) == HRESULT.S_OK) { if (pStore != IntPtr.Zero) { IMsgStore msgStore = Marshal.GetObjectForIUnknown(pStore) as IMsgStore; CurrentStore = new MessageStore(this, msgStore, new EntryID(entryId.AsBytes), storeName); } } SBinary.SBinaryRelease(ref entryId); } } } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine(ex.Message); } return(bResult); }