/// <summary> /// Used for an entry that is to be inserted into the database /// from a recently hashed HashItem. /// </summary> public FileEntry(HashItem item) { ed2k = item.Hash; size = item.Size; if (item.State == 1) path = item.Path; watched = item.Watched; generic = false; }
public void Add(object val) { int key = Hash(val); if (Data[key] == null) Data[key] = new HashItem(val); else { HashItem Cur = new HashItem(val); Cur.Next = Data[key]; Data[key] = Cur; } }
public HashItem ed2kHash(HashItem item) { hasher.Clear(); FileInfo file = new FileInfo(item.Path); using (FileStream fs = file.OpenRead()) { AppendDebugLine("Hashing " + item.Name); byte[] temp; if ((temp = hasher.ComputeHash(fs)) != null) { item.Hash = string.Concat(temp.Select(b => b.ToString("x2")).ToArray()); AppendDebugLine("Ed2k hash: " + item.Hash); return item; } else AppendDebugLine("Hashing aborted"); return null; } }
public void MyListAdd(HashItem item) { Action addToList = new Action(delegate { string r_msg = String.Empty; APIResponse response = Execute(String.Format("MYLISTADD size={0}&ed2k={1}&viewed={2}&state={3}&edit={4}", item.Size, item.Hash, Convert.ToInt32(item.Watched), item.State, Convert.ToInt32(item.Edit))); switch (response.Code) { case RETURN_CODE.MYLIST_ENTRY_ADDED: File(item); r_msg = String.Format("Added {0} to mylist", item.Name); break; case RETURN_CODE.MYLIST_ENTRY_EDITED: File(item); r_msg = String.Format("Edited mylist entry for {0}", item.Name); break; case RETURN_CODE.FILE_ALREADY_IN_MYLIST: // TODO: add auto edit to options. item.Edit = true; MyListAdd(item); return; case RETURN_CODE.NO_SUCH_FILE: r_msg = "Error! File not in database"; break; } AppendDebugLine(r_msg); }); PrioritizedCommand(addToList); }
public void File(HashItem item) { Action fileInfo = new Action(delegate { APIResponse response = Execute(String.Format("FILE size={0}&ed2k={1}&fmask=78006A28B0&amask=F0E0F0C0", item.Size, item.Hash)); if (response.Code == RETURN_CODE.FILE) ParseFileData(item, response.Message); }); PrioritizedCommand(fileInfo); }
public FileWatchedArgs(string f_Path) { Item = new HashItem(f_Path); }
/// <summary> /// Removes a hash entry from the list. /// </summary> /// <param name="item">Item to remove.</param> /// <param name="userRemoved">True if removed by user.</param> private void removeRowFromHashTable(HashItem item, bool userRemoved = false) { if (isHashing && userRemoved) { totalQueueSize -= item.Size; if (item == hashFileList[0]) m_aniDBAPI.cancelHashing(); } lock (m_hashingLock) hashFileList.Remove(item); Dispatcher.BeginInvoke(new Action(delegate { if (hashFileList.Count == 0) hashingStartButton.IsEnabled = hashingStopButton.IsEnabled = false; })); }
/// <summary> /// Adds completed hash item to mylist. /// </summary> private void FinishHash(HashItem item) { ppSize += item.Size; if (item.FromMPC) { m_aniDBAPI.MyListAdd(item); if (ConfigFile.Read("mpcShowOSD").ToBoolean() && m_mpcAPI != null && m_mpcAPI.isHooked) m_mpcAPI.OSDShowMessage(String.Format("{0}: File marked as watched{1}", m_AppName, m_mpcAPI.CurrentFileName != item.Name ? String.Format(", ({0})", item.Name) : String.Empty)); } else if (addToMyListCheckBox.IsChecked == true) { item.Watched = (bool)watchedCheckBox.IsChecked; item.State = stateComboBox.SelectedIndex; m_aniDBAPI.MyListAdd(item); } }
/// <summary> /// Adds a hashItem to the hash list. /// </summary> /// <param name="path">Path to file.</param> private void addRowToHashTable(HashItem item) { hashFileList.Insert(0, item); if (isHashing) totalQueueSize += item.Size; else if (!isHashing) beginHashing(); }
/// <summary> /// Creates a entry and adds it to the hash list. /// </summary> /// <param name="path">Path to file.</param> private void addRowToHashTable(string path) { HashItem item = new HashItem(path); hashFileList.Add(item); if (isHashing) totalQueueSize += item.Size; else if (!isHashing) Dispatcher.BeginInvoke(new Action(delegate { hashingStartButton.IsEnabled = true; })); }