예제 #1
0
        public void Browse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, object _Tag, Delegate_OnBrowseDone _Callback)
        {
            _RequestState state = new _RequestState();

            state.Callback = _Callback;
            state.Tag      = _Tag;
            state.Server   = server;
            server.ContentDirectory.Browse(ObjectID, BrowseFlag, Filter, StartingIndex, RequestedCount, SortCriteria, state, new Intel.UPNP.AV.CpContentDirectory.Delegate_OnResult_Browse(_OnBrowseDone));
        }
        private void Sink_OnBrowse(CpMediaServer server, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, UPnPInvokeException e, Exception parseError, object _Tag, IUPnPMedia[] Result, System.UInt32 NumberReturned, System.UInt32 TotalMatches, System.UInt32 UpdateID)
        {
            if (server == this.m_Server)
            {
                if (ObjectID == this.m_Context)
                {
                    if (_Tag == this.m_Container)
                    {
                        if ((e != null) || (parseError != null))
                        {
                            //error encountered
                        }
                        else
                        {
                            // add children
                            this.m_Children.AddRange(Result);
                            this.m_Container.AddObjects(Result, true);

                            if (this.OnIncrementalUpdate != null)
                            {
                                this.OnIncrementalUpdate(this, Result);
                            }

                            if (
                                ((this.m_Children.Count == TotalMatches) && (NumberReturned > 0)) ||
                                ((TotalMatches == 0) && (NumberReturned > 0))
                                )
                            {
                                // more items to come
                                this.m_CurrentIndex = NumberReturned;
                                DoNextBrowse();
                            }
                            else
                            {
                                lock (this)
                                {
                                    // no more items, prune children from m_Container
                                    ArrayList remove = new ArrayList();
                                    foreach (IUPnPMedia m1 in this.m_Container.CompleteList)
                                    {
                                        bool found = false;
                                        foreach (IUPnPMedia m2 in this.m_Children)
                                        {
                                            if (m1 == m2)
                                            {
                                                found = true;
                                                break;
                                            }
                                        }
                                        if (found == false)
                                        {
                                            remove.Add(m1);
                                        }
                                    }
                                    this.m_Container.RemoveObjects(remove);
                                }

                                if (this.OnRefreshComplete != null)
                                {
                                    IUPnPMedia[] list = (IUPnPMedia[])this.m_Children.ToArray(typeof(IUPnPMedia));
                                    this.OnRefreshComplete(this, list);
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #3
0
        private void _OnBrowseDone(CpContentDirectory sender, System.String ObjectID, Intel.UPNP.AV.CpContentDirectory.Enum_A_ARG_TYPE_BrowseFlag BrowseFlag, System.String Filter, System.UInt32 StartingIndex, System.UInt32 RequestedCount, System.String SortCriteria, System.String Result, System.UInt32 NumberReturned, System.UInt32 TotalMatches, System.UInt32 UpdateID, UPnPInvokeException e, object _Tag)
        {
            _RequestState state = (_RequestState)_Tag;

            if (e != null)
            {
                state.Callback(state.Server, e, null, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
            }
            else
            {
                try
                {
                    ArrayList al = CpMediaBuilder.BuildMediaBranches(Result);
                    state.Callback(state.Server, e, null, state.Tag, (IUPnPMedia[])al.ToArray(typeof(IUPnPMedia)), NumberReturned, TotalMatches, UpdateID);
                }
                catch (Exception parseError)
                {
                    state.Callback(state.Server, e, parseError, state.Tag, null, NumberReturned, TotalMatches, UpdateID);
                }
            }
        }