public ProtocolStatusChangeEventArgs(Protocol protocol, StatusMode newStatus)
 {
     this.newStatus = newStatus;
     this.protocol = protocol;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Get the event information from a <see cref="DBEVENTINFO"/> struct.
        /// </summary>
        /// <param name="dbEventInfo">[REF] <see cref="DBEVENTINFO"/> struct.</param>
        /// <param name="mirandaHandle">Event handle (the blob buffer will be populated if not null).</param>
        /// <param name="blobBuffer">Buffer to use for blob marshaling.</param>
        /// <param name="type">[OUT] Event type.</param>
        /// <param name="flags">[OUT] Event flags.</param>
        /// <param name="data">[OUT] Event data.</param>
        /// <param name="owningModule">[OUT] Event related module.</param>
        /// <param name="timestamp">[OUT] Event timestamp.</param>
        private static void GetEventInfo(ref DBEVENTINFO dbEventInfo, IntPtr eventHandle, InteropBuffer blobBuffer, out DatabaseEventType type, out DatabaseEventProperties flags, out string data, out Protocol owningModule, out DateTime timestamp)
        {
            MirandaContext context = MirandaContext.Current;

            unsafe
            {
                // If the event handle is set, we probably want to populate the blob buffer...
                if (eventHandle != IntPtr.Zero)
                    PopulateBlobBuffer(ref dbEventInfo, eventHandle);

                type = (DatabaseEventType)dbEventInfo.EventType;
                flags = (DatabaseEventProperties)dbEventInfo.Flags;
                data = GetEventData(ref dbEventInfo);
            }

            owningModule = GetEventModule(ref dbEventInfo);
            GetEventTimestamp(ref dbEventInfo, blobBuffer, out timestamp);
        }
Exemplo n.º 3
0
 public static IntPtr LoadProtocolIcon(Protocol protocol, StatusMode status)
 {
     return LoadProtocolIcon((protocol != null ? protocol.Name : null), status);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Gets the event information based on its handle.
        /// </summary>
        /// <param name="eventHandle">Event handle.</param>
        /// <param name="type">[OUT] Event type.</param>
        /// <param name="flags">[OUT] Event flags.</param>
        /// <param name="data">[OUT] Event data.</param>
        /// <param name="owningModule">[OUT] Event related module.</param>
        /// <param name="timestamp">[OUT] Event timestamp.</param>
        public static void FromHandle(IntPtr eventHandle, out DatabaseEventType type, out DatabaseEventProperties flags, out string data, out Protocol owningModule, out DateTime timestamp)
        {
            InteropBuffer buffer = null;

            try
            {
                unsafe
                {
                    DBEVENTINFO dbEventInfo;
                    PrepareDbEventInfo(eventHandle, out dbEventInfo, out buffer);

                    GetEventInfo(ref dbEventInfo, eventHandle, buffer, out type, out flags, out data, out owningModule, out timestamp);
                }
            }
            catch (MirandaException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new InvalidOperationException(TextResources.ExceptionMsg_CannotFinishMarshaling, e);
            }
            finally
            {
                if (buffer != null)
                {
                    buffer.Unlock();
                    InteropBufferPool.ReleaseBuffer(buffer);
                }
            }
        }
Exemplo n.º 5
0
        private unsafe void PopulateNetworkProtocols()
        {
            try
            {
                int count;
                PROTOCOLDESCRIPTOR** pointerArrayPtr;

                int result = CallServiceUnsafe(MirandaServices.MS_PROTO_ENUMPROTOCOLS, &count, &pointerArrayPtr);
                if (result != 0) throw new MirandaException(String.Format(TextResources.ExceptionMsg_Formatable2_MirandaServiceReturnedFailure, MirandaServices.MS_PROTO_ENUMPROTOCOLS, result.ToString()));

                ProtocolDictionary protocols = new ProtocolDictionary(count);

                for (int i = 0; i < count; i++)
                {
                    // *(ptr_to_array_of_ptrs + i * sizeof(PROTOCOLDESCRIPTOR)) = *ptr_to_ptr = *ptr = data
                    PROTOCOLDESCRIPTOR nativeDescriptor = **(((PROTOCOLDESCRIPTOR**)pointerArrayPtr) + i);
                    Protocol protocol = new Protocol(ref nativeDescriptor);

                    protocols.Add(protocol.Name, protocol);
                }

                this.protocols = protocols;
            }
            catch (Exception)
            {
                this.protocols = new ProtocolDictionary(0);
            }
        }