Beispiel #1
0
        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);
        }
Beispiel #2
0
        public bool DownloadDocuments()
        {
            if (!this.prepared)
            {
                LOG.Error("XCAP sevice not prepared");
                return(false);
            }

            this.ready = false;
            this.xcapDocumentsUris.Clear();
            this.rlsPresUri = null;

            lock (this.xcapSelector)
            {
                MyXcapMessage xcapMessage;

                // ============== xcap-caps ============== //
                String xcapCapsUrl;
                lock (this.xcapSelector)
                {
                    this.xcapSelector.reset();
                    this.xcapSelector.setAUID(XcapService.XCAP_AUID_IETF_XCAP_CAPS_ID);
                    xcapCapsUrl = this.xcapSelector.getString();
                }
                xcapMessage = this.xcapStack.GetDocument(xcapCapsUrl);
                // xcap-caps is mandatory ==> continue the process only if all is ok
                if (xcapMessage == null)
                {
                    LOG.Error("Failed to get 'xcap-caps' document");
                    return(false);
                }
                if (!this.handleXcapCapsEvent(xcapMessage.Code, xcapMessage.Content))
                {
                    LOG.Error("Failed to handle 'xcap-caps' document");
                    return(false);
                }


                // ============== org.openmobilealliance.xcap-directory ============== //
                if (this.hasOMADirectory)
                {
                    if (this.xcapStack.IsRunning)
                    {
                        xcapMessage = this.GetWellKnownDocument(XcapService.XCAP_AUID_OMA_DIRECTORY_ID);
                        if (xcapMessage != null)
                        {
                            if (!this.handleOMADirectoryEvent(xcapMessage.Code, xcapMessage.Content))
                            {
                                LOG.Error("Failed to handle 'org.openmobilealliance.xcap-directory' document");
                            }
                        }
                        else
                        {
                            LOG.Error("Failed to get 'org.openmobilealliance.xcap-directory' document");
                        }
                    }
                    else
                    {
                        LOG.Warn("XCAP Stack not running");
                    }
                }
                else
                {
                    LOG.Warn("'org.openmobilealliance.xcap-directory' not supported");
                }

                // ============== resource-lists ============== //
                if (hasResourceLists)
                {
                    if (this.xcapStack.IsRunning)
                    {
                        xcapMessage = this.GetWellKnownDocument(XcapService.XCAP_AUID_IETF_RESOURCE_LISTS_ID);
                        if (xcapMessage != null)
                        {
                            if (!this.HandleResourceListsEvent(xcapMessage.Code, xcapMessage.Content))
                            {
                                LOG.Error("Failed to handle 'resource-lists' document");
                            }
                            else
                            {
                                EventHandlerTrigger.TriggerEvent <XcapEventArgs>(this.onXcapEvent, this,
                                                                                 new XcapEventArgs(XcapEventTypes.RESOURCE_LISTS_DONE, xcapMessage.Code, xcapMessage.Phrase));
                            }
                        }
                        else
                        {
                            LOG.Error("Failed to get 'resource-lists' document");
                        }
                    }
                    else
                    {
                        LOG.Warn("XCAP Stack not running");
                    }
                }
                else
                {
                    LOG.Error("'resource-lists' not supported");
                }

                // ============== rls-services ============== //
                if (this.hasRLS)
                {
                    if (this.xcapStack.IsRunning)
                    {
                        xcapMessage = this.GetWellKnownDocument(XcapService.XCAP_AUID_IETF_RLS_SERVICES_ID);
                        if (xcapMessage != null)
                        {
                            if (!this.HandleRLSEvent(xcapMessage.Code, xcapMessage.Content))
                            {
                                LOG.Error("Failed to handle 'resource-lists' document");
                            }
                            else
                            {
                                EventHandlerTrigger.TriggerEvent <XcapEventArgs>(this.onXcapEvent, this,
                                                                                 new XcapEventArgs(XcapEventTypes.RLS_DONE, xcapMessage.Code, xcapMessage.Phrase));
                            }
                        }
                        else
                        {
                            LOG.Error("Failed to get 'resource-lists' document");
                        }
                    }
                    else
                    {
                        LOG.Warn("XCAP Stack not running");
                    }
                }
                else
                {
                    LOG.Error("'rls-services' not supported");
                }

                // ============== org.openmobilealliance.pres-content ============== //
                if (this.hasOMAPresRules)
                {
                    if (this.xcapStack.IsRunning)
                    {
                        xcapMessage = this.GetWellKnownDocument(XcapService.XCAP_AUID_OMA_PRES_RULES_ID);
                        if (xcapMessage != null)
                        {
                            if (!this.HandleOMAPresRules(xcapMessage.Code, xcapMessage.Content))
                            {
                                LOG.Error("Failed to handle 'org.openmobilealliance.pres-content' document");
                            }
                        }
                        else
                        {
                            LOG.Error("Failed to get 'org.openmobilealliance.pres-content' document");
                        }
                    }
                    else
                    {
                        LOG.Warn("XCAP Stack not running");
                    }
                }
                else
                {
                    LOG.Error("'org.openmobilealliance.pres-content' not supported");
                }

                // ============== org.openmobilealliance.pres-content ============== //
                if (this.hasOMAPresenceContent)
                {
                    if (this.xcapStack.IsRunning)
                    {
                        xcapMessage = this.GetWellKnownDocument(XcapService.XCAP_AUID_OMA_PRES_CONTENT_ID);
                        if (xcapMessage != null)
                        {
                            if (!this.HandlePresContent(xcapMessage.Code, xcapMessage.Content))
                            {
                                LOG.Error("Failed to handle 'org.openmobilealliance.pres-content' document");
                            }
                            else
                            {
                                XcapEventArgs eargs = new XcapEventArgs(XcapEventTypes.PRESCONTENT_DONE, xcapMessage.Code, xcapMessage.Phrase);
                                eargs.AddExtra(XcapEventArgs.EXTRA_CONTENT, this.Avatar);
                                EventHandlerTrigger.TriggerEvent <XcapEventArgs>(this.onXcapEvent, this, eargs);
                            }
                        }
                        else
                        {
                            LOG.Error("Failed to get 'org.openmobilealliance.pres-content' document");
                        }
                    }
                    else
                    {
                        LOG.Warn("XCAP Stack not running");
                    }
                }
            }

            this.ready = true;

            return(true);
        }