예제 #1
0
파일: Helpers.cs 프로젝트: Xen0byte/xdm
        public static string GenerateStatusText(InProgressDownloadItem ent)
        {
            var text = string.Empty;

            if (ent.Status == DownloadStatus.Downloading)
            {
                if (string.IsNullOrEmpty(ent.ETA) && string.IsNullOrEmpty(ent.DownloadSpeed))
                {
                    text = GetStatusText(ent.Status);
                }
                else if (string.IsNullOrEmpty(ent.ETA))
                {
                    text = ent.DownloadSpeed ?? string.Empty;
                }
                else if (string.IsNullOrEmpty(ent.DownloadSpeed))
                {
                    text = ent.ETA ?? string.Empty;
                }
                else
                {
                    text = $"{ent.DownloadSpeed} - {ent.ETA}";
                }
            }
            else
            {
                text = GetStatusText(ent.Status);
            }

            return(text);
        }
예제 #2
0
 internal InProgressEntryWrapper(InProgressDownloadItem downloadEntry,
                                 TreeIter treeIter,
                                 ITreeModel store)
 {
     this.DownloadEntry = downloadEntry;
     this.treeIter      = treeIter;
     this.store         = store;
 }
예제 #3
0
        public void ShowRefreshLinkDialog(InProgressDownloadItem entry)
        {
            var dlg = LinkRefreshWindow.CreateFromGladeFile();
            var ret = LinkRefreshDialogUIController.RefreshLink(entry, dlg);

            if (!ret)
            {
                GtkHelper.ShowMessageBox(GetMainWindow(), TextResource.GetText("NO_REFRESH_LINK"));
                return;
            }
        }
예제 #4
0
 public bool AddNewDownload(InProgressDownloadItem entry)
 {
     lock (db)
     {
         try
         {
             if (cmdInsertOne == null)
             {
                 cmdInsertOne = new SQLiteCommand(@"INSERT INTO downloads(
                                     id, completed, name, date_added, size, status, 
                                     progress, download_type, filenamefetchmode, maxspeedlimitinkib, targetdir, primary_url,
                                     referer_url, auth, user, pass, proxy, proxy_host,
                                     proxy_port, proxy_user, proxy_pass, proxy_type)
                                     VALUES(
                                     @id, @completed, @name, @date_added, @size, @status, 
                                     @progress, @download_type, @filenamefetchmode, @maxspeedlimitinkib, @targetdir, @primary_url,
                                     @referer_url, @auth, @user, @pass, @proxy, @proxy_host, 
                                     @proxy_port, @proxy_user, @proxy_pass, @proxy_type)", db);
             }
             SetParam("@id", entry.Id, cmdInsertOne.Parameters);
             SetParam("@completed", 0, cmdInsertOne.Parameters);
             SetParam("@name", entry.Name, cmdInsertOne.Parameters);
             SetParam("@date_added", entry.DateAdded.ToBinary(), cmdInsertOne.Parameters);
             SetParam("@size", entry.Size, cmdInsertOne.Parameters);
             SetParam("@status", (int)entry.Status, cmdInsertOne.Parameters);
             SetParam("@progress", entry.Progress, cmdInsertOne.Parameters);
             SetParam("@download_type", entry.DownloadType, cmdInsertOne.Parameters);
             SetParam("@filenamefetchmode", (int)entry.FileNameFetchMode, cmdInsertOne.Parameters);
             SetParam("@maxspeedlimitinkib", entry.MaxSpeedLimitInKiB, cmdInsertOne.Parameters);
             SetParam("@targetdir", entry.TargetDir, cmdInsertOne.Parameters);
             SetParam("@primary_url", entry.PrimaryUrl, cmdInsertOne.Parameters);
             SetParam("@referer_url", entry.RefererUrl, cmdInsertOne.Parameters);
             SetParam("@auth", entry.Authentication.HasValue ? 1 : 0, cmdInsertOne.Parameters);
             SetParam("@user", entry.Authentication?.UserName ?? null, cmdInsertOne.Parameters);
             SetParam("@pass", entry.Authentication?.Password ?? null, cmdInsertOne.Parameters);
             SetParam("@proxy", (int)(entry.Proxy?.ProxyType ?? 0), cmdInsertOne.Parameters);
             SetParam("@proxy_host", entry.Proxy?.Host ?? null, cmdInsertOne.Parameters);
             SetParam("@proxy_port", (int)(entry.Proxy?.Port ?? 0), cmdInsertOne.Parameters);
             SetParam("@proxy_user", entry.Proxy?.UserName ?? null, cmdInsertOne.Parameters);
             SetParam("@proxy_pass", entry.Proxy?.Password ?? null, cmdInsertOne.Parameters);
             SetParam("@proxy_type", 1, cmdInsertOne.Parameters);
             cmdInsertOne.ExecuteNonQuery();
             return(true);
         }
         catch (Exception ex)
         {
             Log.Debug(ex, ex.Message);
             return(false);
         }
     }
 }
예제 #5
0
 internal InProgressDownloadEntryWrapper(InProgressDownloadItem entry)
 {
     this.entry = entry;
 }
 public InProgressDownloadEntryWrapper(InProgressDownloadItem entry)
 {
     this.entry = entry;
 }