コード例 #1
0
ファイル: ContactService.cs プロジェクト: yuanjianjiang/boghe
        private void GroupSignal(Group group, ContactEventTypes eventType)
        {
            ContactEventArgs eargs = new ContactEventArgs(eventType);

            eargs.AddExtra(ContactEventArgs.EXTRA_GROUP, group);
            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
        }
コード例 #2
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool DeleteGroup(Group parent, Group group)
        {
            bool result;

            if (parent == null || null == group)
            {
                result = false;
            }
            else
            {
                foreach (ContactItem contact in parent.Children)
                {
                    if (contact == group)
                    {
                        parent.Children.Remove(contact);
                        ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.GROUP_REMOVED);
                        eargs.AddExtra("group", group);
                        EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
                        result = true;
                        return(result);
                    }
                    if (contact is Group && contact.Children.Count > 0)
                    {
                        if (this.DeleteGroup(contact as Group, group))
                        {
                            result = true;
                            return(result);
                        }
                    }
                }
                result = false;
            }
            return(result);
        }
コード例 #3
0
        public int CancelTask()
        {
            int ret = -1;

            try
            {
                CleanTask();

                if (this.OnServiceTaskEndHandler != null)
                {
                    EventHandlerTrigger.TriggerEvent <ServiceTaskEndEventArgs>(this.OnServiceTaskEndHandler, this,
                                                                               new ServiceTaskEndEventArgs(this));
                }

                ret = 0;
            }
            catch (System.Exception ex)
            {
                // Logger.LogError(className, ":" + ex.Message);
                QueueInstance.Instance.AddMyLogList(System.DateTime.Now.ToString() + "结束任务捕获未知异常" + ex.Message);
                ret = 9;
            }
            finally
            {
                this.isRunning  = false;
                this.isCanceled = true;
            }
            return(ret);
        }
コード例 #4
0
ファイル: ContactService.cs プロジェクト: yuanjianjiang/boghe
        private void ContactSignal(Contact contact, ContactEventTypes eventType)
        {
            ContactEventArgs eargs = new ContactEventArgs(eventType);

            eargs.AddExtra(ContactEventArgs.EXTRA_CONTACT, contact);
            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
        }
コード例 #5
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool AddPerson2Group(Group group, System.Collections.Generic.List <Person> persons)
        {
            bool result;

            if (group == null || null == persons)
            {
                result = false;
            }
            else
            {
                string strDPSUser = UriUtils.GetUserName(this.serviceManager.ConfigurationService.IdentityCfg.Impi);
                foreach (Person person in persons)
                {
                    string strPersonName = UriUtils.GetUserName(person.Uri);
                    if (!strDPSUser.Equals(person.UDN, System.StringComparison.InvariantCultureIgnoreCase) && !strDPSUser.Equals(strPersonName, System.StringComparison.InvariantCultureIgnoreCase))
                    {
                        group.Children.Add(person);
                        person.Parent = group;
                    }
                }
                ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_ADDED);
                eargs.AddExtra("parent", group);
                eargs.AddExtra("contact", persons);
                EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
                result = true;
            }
            return(result);
        }
コード例 #6
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool AddGroup(Group group, ContactItem parent)
        {
            bool result;

            if (group == null || parent == null)
            {
                result = false;
            }
            else if (this.FindItem(group.GDN, ContactType.Group) != null)
            {
                result = false;
            }
            else
            {
                lock (parent)
                {
                    parent.Children.Add(group);
                    group.Parent = parent;
                }
                ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.GROUP_ADDED);
                eargs.AddExtra("group", group);
                eargs.AddExtra("parent", parent);
                EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
                result = true;
            }
            return(result);
        }
コード例 #7
0
        public void onRegistrationEvent(object sender, RegistrationEventArgs e)
        {
            switch (e.Type)
            {
            case RegistrationEventTypes.REGISTRATION_OK:
                this.anStatus     = ANStatus.INSERVICE;
                this.isRegistered = true;
                break;

            case RegistrationEventTypes.REGISTRATION_NOK:
                this.anStatus = ANStatus.STACK_STARTED;
                break;

            case RegistrationEventTypes.REGISTRATION_INPROGRESS:
                this.anStatus = ANStatus.REGISTERING;
                break;

            case RegistrationEventTypes.UNREGISTRATION_OK:
                this.anStatus     = ANStatus.UNREGISTERED;
                this.isRegistered = false;
                this.StopHeartbeatDetector();
                break;

            case RegistrationEventTypes.UNREGISTRATION_NOK:
                this.anStatus = ANStatus.INSERVICE;
                break;

            case RegistrationEventTypes.UNREGISTRATION_INPROGRESS:
                this.anStatus = ANStatus.UNREGISTERING;
                break;
            }
            EventHandlerTrigger.TriggerEvent <AccessNetworkEventArgs>(this.onAccessNetworkEvent, this, new AccessNetworkEventArgs(AccessNetworkEventTypes.ANET_LOGIN, this.anStatus, e.Phrase));
        }
コード例 #8
0
            private void ProcessResponse(MsrpMessage message)
            {
                short code = message.getCode();

                if (code >= 200 && code <= 299)
                {
                    // File Transfer => ProgressBar
                    if (this.session.MediaType == MediaType.FileTransfer)
                    {
                        long start = -1, end = -1, total = -1;
                        message.getByteRange(out start, out end, out total);
                        MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.SUCCESS_2XX);
                        eargs.AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_START, start)
                        .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_END, end)
                        .AddExtra(MsrpEventArgs.EXTRA_BYTE_RANGE_TOTAL, total)
                        .AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code)
                        .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                        EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                    }
                }
                else if (code >= 300)
                {
                    MsrpEventArgs eargs = new MsrpEventArgs(this.session.Id, MsrpEventTypes.ERROR);
                    eargs.AddExtra(MsrpEventArgs.EXTRA_RESPONSE_CODE, code)
                    .AddExtra(MsrpEventArgs.EXTRA_SESSION, this.session);
                    EventHandlerTrigger.TriggerEvent <MsrpEventArgs>(this.session.onMsrpEvent, this.session, eargs);
                }
            }
コード例 #9
0
 private void LoadHistory()
 {
     this.loading = true;
     HistoryService.LOG.Debug(string.Format("Loading history from {0}", this.fileFullPath));
     try
     {
         if (!System.IO.File.Exists(this.fileFullPath))
         {
             HistoryService.LOG.Debug(string.Format("{0} doesn't exist, trying to create new one", this.fileFullPath));
             System.IO.File.Create(this.fileFullPath).Close();
             this.events = new MyObservableCollection <HistoryItem>();
             this.ImmediateSave();
         }
         using (System.IO.StreamReader reader = new System.IO.StreamReader(this.fileFullPath))
         {
             try
             {
                 this.events = (this.xmlSerializer.Deserialize(reader) as MyObservableCollection <HistoryItem>);
             }
             catch (System.InvalidOperationException ie)
             {
                 HistoryService.LOG.Error("Failed to load history", ie);
                 reader.Close();
                 System.IO.File.Delete(this.fileFullPath);
             }
         }
     }
     catch (System.Exception e)
     {
         HistoryService.LOG.Error("Failed to load history", e);
     }
     this.loading = false;
     EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET));
 }
コード例 #10
0
ファイル: XcapService.cs プロジェクト: xolile/boghe
        public bool AvatarPublish(String base64Content, String mimeType)
        {
            if (!this.prepared)
            {
                LOG.Error("XCAP sevice not prepared");
                return(false);
            }
            if (!this.hasOMAPresenceContent)
            {
                LOG.Error("OMAPresenceContent not supported");
                return(false);
            }

            new System.Threading.Thread(delegate()
            {
                if (this.CreatePresenceContentDocument(base64Content, mimeType))
                {
                    this.Avatar         = base64Content;
                    XcapEventArgs eargs = new XcapEventArgs(XcapEventTypes.PRESCONTENT_DONE, 200, "OK");
                    eargs.AddExtra(XcapEventArgs.EXTRA_CONTENT, this.Avatar);
                    EventHandlerTrigger.TriggerEvent <XcapEventArgs>(this.onXcapEvent, this, eargs);
                }
            })
            .Start();

            return(true);
        }
コード例 #11
0
        public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value)
        {
            if (value == null)
            {
                return(false);
            }

            try
            {
                using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString()))
                {
                    regkey.SetValue(entry.ToString(), value);
                    regkey.Close();
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to set value into registry", e);
                return(false);
            }

            // Trigger
            EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

            return(true);
        }
コード例 #12
0
        public void UpdateEvent(HistoryItem @event)
        {
            HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.UPDATED);

            eargs.AddExtra("event", @event);
            EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs);
            this.DeferredSave();
        }
コード例 #13
0
ファイル: ContactService.cs プロジェクト: yuanjianjiang/boghe
        public void UpdateGroupsAndContacts(List <Group> freshGroups, List <Contact> freshContacts)
        {
            this.groups.ReplaceRange(freshGroups);
            this.contacts.ReplaceRange(freshContacts);


            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, new ContactEventArgs(ContactEventTypes.RESET));
        }
コード例 #14
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool UpdatePersonInfo(Person person)
        {
            ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_UPDATED);

            eargs.AddExtra("contact", person);
            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
            return(true);
        }
コード例 #15
0
 public void ClearStates()
 {
     lock (this.states)
     {
         this.states.Clear();
         EventHandlerTrigger.TriggerEvent <StateMonitorEventArgs>(this.onStateChangedEvent, this, new StateMonitorEventArgs(StateMonitorEventTypes.CLEARED, null, null));
     }
 }
コード例 #16
0
ファイル: IMActivityIndicator.cs プロジェクト: zzh56/boghe
 public void OnContentReceived()
 {
     lock (this)
     {
         this.is_remote_active = false;
         EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this);
     }
 }
コード例 #17
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool DelPersonInGroup(Group group, System.Collections.Generic.List <Person> persons)
        {
            ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_REMOVED);

            eargs.AddExtra("parent", group);
            eargs.AddExtra("contact", persons);
            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
            return(true);
        }
コード例 #18
0
        public void AddEvent(HistoryItem @event)
        {
            this.events.Insert(0, @event);
            HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.ADDED);

            eargs.AddExtra("event", @event);
            EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs);
            this.DeferredSave();
        }
コード例 #19
0
        public void DeleteEvent(HistoryItem @event)
        {
            this.events.Remove(@event);
            HistoryEventArgs eargs = new HistoryEventArgs(HistoryEventTypes.REMOVED);

            eargs.AddExtra("event", @event);
            EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, eargs);
            this.DeferredSave();
        }
コード例 #20
0
ファイル: ContactService.cs プロジェクト: feimorpheusma/MWS
        public bool DelPersonInGroup(Group group, Person person)
        {
            ContactEventArgs eargs = new ContactEventArgs(ContactEventTypes.CONTACT_REMOVED);

            eargs.AddExtra("parent", group);
            eargs.AddExtra("contact", person);
            EventHandlerTrigger.TriggerEvent <ContactEventArgs>(this.onContactEvent, this, eargs);
            return(true);
        }
コード例 #21
0
ファイル: MainInstH264.cs プロジェクト: sarandogou/thialgou
 public override int OnElt(CommonElt elt)
 {
     if (OnEvent != null)
     {
         // Because the event is delivered asynchronously we must copy the elt HERE before the native memory (C++) is destroyed.
         Elt element = Elt.New(elt);
         EventHandlerTrigger.TriggerEvent <EltEventArgs>(OnEvent, this, new EltEventArgs(element));
     }
     return(0);
 }
コード例 #22
0
 private void systimer_local_active_Elapsed(object sender, ElapsedEventArgs e)
 {
     lock (this)
     {
         if (this.is_local_active)
         {
             EventHandlerTrigger.TriggerEvent(this.sendMessageEvent, this);
         }
     }
 }
コード例 #23
0
ファイル: SipService.cs プロジェクト: zzh56/boghe
 public bool RaiseEvent(EventArgs eargs)
 {
     if (eargs is MessagingEventArgs)
     {
         EventHandlerTrigger.TriggerEvent <MessagingEventArgs>(this.onMessagingEvent, this, (eargs as MessagingEventArgs));
         return(true);
     }
     LOG.Error("Cannot raise event with type = " + eargs);
     return(false);
 }
コード例 #24
0
ファイル: HistoryService.cs プロジェクト: yuanjianjiang/boghe
        private void LoadHistory()
        {
            this.loading = true;

            LOG.Debug(String.Format("Loading history from {0}", this.fileFullPath));

            try
            {
#if WINRT
                if (!IsolatedStorageFile.GetUserStoreForApplication().FileExists(this.fileFullPath))
#else
                if (!File.Exists(this.fileFullPath))
#endif
                {
                    LOG.Debug(String.Format("{0} doesn't exist, trying to create new one", this.fileFullPath));

#if WINRT
                    IsolatedStorageFile.GetUserStoreForApplication().CreateFile(this.fileFullPath).Close();
#else
                    File.Create(this.fileFullPath).Close();
#endif

                    // create xml declaration
                    this.events = new MyObservableCollection <HistoryEvent>();
                    this.ImmediateSave();
                }

#if WINRT
                using (StreamReader reader = new StreamReader(new IsolatedStorageFileStream(this.fileFullPath, FileMode.OpenOrCreate, IsolatedStorageFile.GetUserStoreForApplication())))
#else
                using (StreamReader reader = new StreamReader(this.fileFullPath))
#endif
                {
                    try
                    {
                        this.events = this.xmlSerializer.Deserialize(reader) as MyObservableCollection <HistoryEvent>;
                    }
                    catch (InvalidOperationException ie)
                    {
                        LOG.Error("Failed to load history", ie);

                        reader.Close();
                        File.Delete(this.fileFullPath);
                    }
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to load history", e);
            }

            this.loading = false;

            EventHandlerTrigger.TriggerEvent <HistoryEventArgs>(this.onHistoryEvent, this, new HistoryEventArgs(HistoryEventTypes.RESET));
        }
コード例 #25
0
 public override Int32 OnErrorHdr(h264HdrType_t eType)
 {
     lock (mParser)
     {
         if (mParser.onEvent != null)
         {
             EventHandlerTrigger.TriggerEvent <HdrEventParseArgs>(mParser.onEvent, mParser, new HdrEventParseArgsH264(HdrEventParseType.ErrorHdr, eType));
         }
     }
     return(0);
 }
コード例 #26
0
 private void systimer_remote_active_Elapsed(object sender, ElapsedEventArgs e)
 {
     lock (this)
     {
         if (this.is_remote_active)
         {
             this.is_remote_active = false;
         }
         EventHandlerTrigger.TriggerEvent(this.remoteStateChangedEvent, this);
     }
 }
コード例 #27
0
        public bool InternalSet(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
        {
            lock (this)
            {
                IsolatedStorageSettings.ApplicationSettings[BuildKey(folder, entry)] = value;
                EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

                this.DeferredSave();
                return(true);
            }
        }
コード例 #28
0
 public override Int32 OnFrameDraw(IntPtr pLum, IntPtr pCb, IntPtr pCr, uint uiWidth, uint uiHeight, uint uiStride)
 {
     lock (mParser)
     {
         if (mParser.onEventData != null)
         {
             FrameEventDrawArgs args = new FrameEventDrawArgs(0 /*FIXME*/, pLum, pCb, pCr, uiWidth, uiHeight, uiStride);
             EventHandlerTrigger.TriggerEvent <FrameEventDrawArgs>(mParser.onEventData, mParser, args);
         }
     }
     return(0);
 }
コード例 #29
0
 public void RemoveState(String stateKey)
 {
     lock (this.states)
     {
         if (this.states.ContainsKey(stateKey))
         {
             String stateDescription = this.states[stateKey];
             this.states.Remove(stateKey);
             EventHandlerTrigger.TriggerEvent <StateMonitorEventArgs>(this.onStateChangedEvent, this, new StateMonitorEventArgs(StateMonitorEventTypes.REMOVED, stateKey, stateDescription));
         }
     }
 }
コード例 #30
0
ファイル: IMActivityIndicator.cs プロジェクト: zzh56/boghe
 private void systimer_local_active_Elapsed(object sender, ElapsedEventArgs e)
 {
     // You are sender
     lock (this)
     {
         if (this.is_local_active)
         {
             // We were active, and we are still active --> do not switch state but raise event
             EventHandlerTrigger.TriggerEvent(this.sendMessageEvent, this);
         }
     }
 }