Ejemplo n.º 1
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     if (_welcomePage == null)
     {
         FillCanvas();
     }
     if (CIX.Online)
     {
         CIX.RefreshOnlineUsers();
         FolderCollection.RefreshInterestingThreads();
     }
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Display the directory for the specified CategoryFolder
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
        {
            CategoryFolder category = folder as CategoryFolder;

            if (category != null)
            {
                if (flags.HasFlag(FolderOptions.ClearFilter))
                {
                    _currentFilterString = null;
                }
                _currentCategory = category;
                _items           = ItemsForView();
                SortItems();
            }
            return(true);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Display the page for the specified forum.
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
        {
            if (folder is TopicFolder)
            {
                _currentFolder = (TopicFolder)folder;
                _thisForum     = CIX.DirectoryCollection.ForumByName(_currentFolder.Name);

                FoldersTree.SetTopicName(folder.Name);

                if (CIX.Online)
                {
                    CIX.DirectoryCollection.RefreshForum(folder.Name);
                }

                FillCanvas();
            }
            return(true);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Display this view with the specified folder and options
 /// </summary>
 public virtual bool ViewFromFolder(FolderBase folder, Address address, FolderOptions flags)
 {
     return(true);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Action: Browse
        /// </summary>
        /// <param name="objectId">Associated State Variable: A_ARG_TYPE_ObjectID</param>
        /// <param name="browseFlag">Associated State Variable: A_ARG_TYPE_BrowseFlag</param>
        /// <param name="filter">Associated State Variable: A_ARG_TYPE_Filter</param>
        /// <param name="startingIndex">Associated State Variable: A_ARG_TYPE_Index</param>
        /// <param name="requestedCount">Associated State Variable: A_ARG_TYPE_Count</param>
        /// <param name="sortCriteria">Associated State Variable: A_ARG_TYPE_SortCriteria</param>
        /// <param name="result">Associated State Variable: A_ARG_TYPE_Result</param>
        /// <param name="numberReturned">Associated State Variable: A_ARG_TYPE_Count</param>
        /// <param name="totalMatches">Associated State Variable: A_ARG_TYPE_Count</param>
        /// <param name="updateID">Associated State Variable: A_ARG_TYPE_UpdateID</param>
        public override void Browse(String objectId, Enum_A_ARG_TYPE_BrowseFlag browseFlag, String filter, UInt32 startingIndex,
                                    UInt32 requestedCount, String sortCriteria, out String result, out UInt32 numberReturned, out UInt32 totalMatches,
                                    out UInt32 updateID)
        {
            updateID       = 0;
            numberReturned = 0;
            totalMatches   = 0;
            StringBuilder sb = new StringBuilder();

            sb.AppendLine(@"<DIDL-Lite xmlns:dc=""http://purl.org/dc/elements/1.1/"" " +
                          @"xmlns:upnp=""urn:schemas-upnp-org:metadata-1-0/upnp/"" " +
                          @"xmlns=""urn:schemas-upnp-org:metadata-1-0/DIDL-Lite/"">");
            try
            {
                FolderBase folder    = (objectId == "0" || objectId == "-1") ? new MainEntry() : GetFolder(objectId);
                var        userAgent = GetUserAgent();

                switch (browseFlag)
                {
                case Enum_A_ARG_TYPE_BrowseFlag.BROWSEDIRECTCHILDREN:
                    bool isFreeboxV5 = (userAgent == UserAgent.FreeboxV5);
                    if (isFreeboxV5)
                    {
                        // In order to enchain the audio files on the Freebox V5
                        IPAddress address = GetCaller().Address;
                        if (Files.ContainsKey(address))
                        {
                            Files.Remove(address);
                        }
                    }

                    FolderBase   subFolder;
                    BrowseResult browseResult;
                    bool         exit = false;
                    do
                    {
                        // Browse the folder
                        browseResult = folder.Browse(startingIndex, requestedCount, userAgent);

                        if (browseResult != null && browseResult.TotalCount == 1 && browseResult.Entries.Count > 0)
                        {
                            // If there is only 1 folder, we will browse the subfolder
                            subFolder = browseResult.Entries[0] as FolderBase;
                            if (subFolder == null)
                            {
                                exit = true;
                            }
                            else
                            {
                                folder = subFolder;
                            }
                        }
                        else
                        {
                            exit = true;
                        }
                    }while (!exit);

                    if (browseResult != null)
                    {
                        bool   v6Workaround = (userAgent == UserAgent.FreeboxV6 && !folder.UsePathAsId && String.IsNullOrEmpty(folder.Path));
                        string line;
                        string dcTitle = "<dc:title>";
                        var    format  = dcTitle + Podcast.GetLinesNumberingFormat(browseResult.TotalCount);
                        int    i       = 1;
                        foreach (var entry in browseResult.Entries)
                        {
                            if (entry is Shutdown && Application.IsMono)
                            {
                                // Unable to shutdown on Linux, Mac
                                browseResult.TotalCount -= 1;
                                continue;
                            }

                            line = entry.ToString(GetReceiver(), objectId, userAgent);
                            if (line == null)
                            {
                                browseResult.TotalCount -= 1;
                                continue;
                            }

                            if (v6Workaround)
                            {
                                // To keep the order of the folders
                                line = line.Replace(dcTitle, String.Format(format, i + startingIndex, String.Empty));
                                i   += 1;
                            }
                            sb.AppendLine(line);
                            numberReturned += 1;
                            AddToFileList(entry, isFreeboxV5);
                        }
                        totalMatches = (uint)browseResult.TotalCount;
                    }
                    break;

                default:
                    sb.AppendLine((folder ?? (Entry) new Entries.File()
                    {
                        Path = HttpUtility.UrlDecode(objectId)
                    }).ToString(GetReceiver(), "-1", userAgent));
                    numberReturned = 1;
                    totalMatches   = 1;
                    break;
                }
            }
            catch (Exception ex)
            {
                Utils.WriteException(ex);
            }
            sb.Append(@"</DIDL-Lite>");
            result = sb.ToString();
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Display the directory for the specified CategoryFolder
        /// </summary>
        public override bool ViewFromFolder(FolderBase folder, Address address, FolderOptions options)
        {
            if (folder != _currentFolder)
            {
                _currentFolder = folder;
                SortConversations();
            }

            // If an address is specified then it refers to a conversation ID that
            // needs to be selected. If it is not found, the first message is selected
            // instead.
            if (address != null && address.Scheme == "cixmailbox")
            {
                int selectedID;

                Int32.TryParse(address.Data, out selectedID);

                int selectedIndex;
                for (selectedIndex = 0; selectedIndex < _conversations.Count; ++selectedIndex)
                {
                    InboxConversation conversation = _conversations[selectedIndex];
                    if (conversation.RemoteID == selectedID)
                    {
                        break;
                    }
                }
                if (selectedIndex == _conversations.Count)
                {
                    selectedIndex = 0;
                }
                SelectedRow = selectedIndex;
                if (address.Unread)
                {
                    SelectedMessage.MarkUnread();
                }
                return(true);
            }

            // If options are specified then search for the next unread
            // in the list otherwise set the initial selection to something
            // useful.
            if (options == 0 && SelectedRow == -1)
            {
                SetInitialSelection();
            }
            else
            {
                int row = inboxConversations.SearchRow;
                if (row < 0 || options.HasFlag(FolderOptions.Reset))
                {
                    row = 0;
                }
                else if (_conversations.Count > 0)
                {
                    InboxConversation conversation = _conversations[row];
                    if (conversation.UnreadCount > 0)
                    {
                        conversation.MarkRead();
                    }
                }
                if (!FirstUnreadAfterRow(row, options))
                {
                    inboxConversations.SearchRow = 0;
                    return(false);
                }
            }

            FoldersTree.SetTopicName(_currentFolder.FullName);

            ActiveControl = inboxConversations;
            inboxConversations.Focus();
            return(true);
        }