示例#1
0
文件: list.cpp 项目: Hydro8182/taiga
int SortAsEpisodeRange(const std::wstring& str1, const std::wstring& str2) {
  auto is_volume = [](const std::wstring& str) {
    return !str.empty() && !IsNumericChar(str.front());
  };
  auto get_last_number_in_range = [](const std::wstring& str) {
    auto pos = InStr(str, L"-");
    return pos > -1 ? ToInt(str.substr(pos + 1)) : ToInt(str);
  };
  auto get_volume = [&](const std::wstring& str) {
    auto pos = InStr(str, L" ");
    return pos > -1 ? get_last_number_in_range(str.substr(pos + 1)) : 0;
  };

  bool is_volume1 = is_volume(str1);
  bool is_volume2 = is_volume(str2);

  if (is_volume1 && is_volume2) {
    return CompareValues<int>(get_volume(str1), get_volume(str2));
  } else if (!is_volume1 && !is_volume2) {
    return CompareValues<int>(get_last_number_in_range(str1),
                              get_last_number_in_range(str2));
  } else {
    return is_volume1 ? base::kLessThan : base::kGreaterThan;
  }
}
示例#2
0
bool Filters::FilterText(const Item& item) const {
  std::vector<std::wstring> words;
  Split(text, L" ", words);
  RemoveEmptyStrings(words);

  std::vector<std::wstring> titles;
  GetAllTitles(item.GetId(), titles);

  const auto& genres = item.GetGenres();

  for (const auto& word : words) {
    auto check_strings = [&word](const std::vector<std::wstring>& v) {
      for (const auto& str : v) {
        if (InStr(str, word, 0, true) > -1)
          return true;
      }
      return false;
    };
    if (!check_strings(titles) &&
        !check_strings(genres) &&
        InStr(item.GetMyTags(), word, 0, true) == -1)
      return false;
  }

  return true;
}
示例#3
0
// Search an entry
IPTABLES_ENTRY *SearchIpTables(IPTABLES_STATE *s, char *chain, IP *src_ip, IP *dest_ip, UINT mark)
{
	char ip_str1[64];
	char ip_str2[64];
	char mark_str1[64];
	char mark_str2[64];
	UINT i;
	if (s == NULL || chain == NULL || src_ip == NULL || dest_ip == NULL || mark == 0)
	{
		return NULL;
	}

	IPToStr(ip_str1, sizeof(ip_str1), src_ip);
	IPToStr(ip_str2, sizeof(ip_str2), dest_ip);
	ToStr(mark_str1, mark);
	Format(mark_str2, sizeof(mark_str2), "%x", mark);

	for (i = 0;i < LIST_NUM(s->EntryList);i++)
	{
		IPTABLES_ENTRY *e = LIST_DATA(s->EntryList, i);

		if (StrCmpi(e->Chain, chain) == 0)
		{
			if (InStr(e->ConditionAndArgs, ip_str1) &&
				InStr(e->ConditionAndArgs, ip_str2) &&
				(InStr(e->ConditionAndArgs, mark_str1) || InStr(e->ConditionAndArgs, mark_str2)))
			{
				return e;
			}
		}
	}

	return NULL;
}
示例#4
0
文件: feed.cpp 项目: Greathood/taiga
bool Feed::Load() {
  // Initialize
  wstring file = GetDataPath() + L"feed.xml";
  items.clear();

  // Load XML file
  xml_document doc;
  xml_parse_result result = doc.load_file(file.c_str());
  if (result.status != status_ok) {
    return false;
  }

  // Read channel information
  xml_node channel = doc.child(L"rss").child(L"channel");
  title = XML_ReadStrValue(channel, L"title");
  link = XML_ReadStrValue(channel, L"link");
  description = XML_ReadStrValue(channel, L"description");

  // Read items
  for (xml_node item = channel.child(L"item"); item; item = item.next_sibling(L"item")) {
    // Read data
    items.resize(items.size() + 1);
    items.back().index = items.size() - 1;
    items.back().category = XML_ReadStrValue(item, L"category");
    items.back().title = XML_ReadStrValue(item, L"title");
    items.back().link = XML_ReadStrValue(item, L"link");
    items.back().description = XML_ReadStrValue(item, L"description");
    
    // Remove if title or link is empty
    if (category == FEED_CATEGORY_LINK) {
      if (items.back().title.empty() || items.back().link.empty()) {
        items.pop_back();
        continue;
      }
    }
    
    // Clean up title
    DecodeHtmlEntities(items.back().title);
    Replace(items.back().title, L"\\'", L"'");
    // Clean up description
    Replace(items.back().description, L"<br/>", L"\n");
    Replace(items.back().description, L"<br />", L"\n");
    StripHtmlTags(items.back().description);
    DecodeHtmlEntities(items.back().description);
    Trim(items.back().description, L" \n");
    Aggregator.ParseDescription(items.back(), link);
    Replace(items.back().description, L"\n", L" | ");
    // Get download link
    if (InStr(items.back().link, L"nyaatorrents", 0, true) > -1) {
      Replace(items.back().link, L"torrentinfo", L"download");
    }
  }

  return true;
}
示例#5
0
bool Filters::CheckItem(Item& item) {
  // Filter my status
  for (size_t i = 0; i < my_status.size(); i++)
    if (!my_status.at(i) && item.GetMyStatus() == i)
      return false;

  // Filter airing status
  for (size_t i = 0; i < status.size(); i++)
    if (!status.at(i) && item.GetAiringStatus() == i + 1)
      return false;

  // Filter type
  for (size_t i = 0; i < type.size(); i++)
    if (!type.at(i) && item.GetType() == i + 1)
      return false;

  // Filter text
  vector<wstring> words;
  Split(text, L" ", words);
  RemoveEmptyStrings(words);
  for (auto it = words.begin(); it != words.end(); ++it) {
    if (InStr(item.GetTitle(), *it, 0, true) == -1 && 
        InStr(item.GetGenres(), *it, 0, true) == -1 && 
        InStr(item.GetMyTags(), *it, 0, true) == -1) {
      bool found = false;
      for (auto synonym = item.GetSynonyms().begin(); 
           !found && synonym != item.GetSynonyms().end(); ++synonym)
        if (InStr(*synonym, *it, 0, true) > -1) found = true;
      if (item.IsInList())
        for (auto synonym = item.GetUserSynonyms().begin(); 
             !found && synonym != item.GetUserSynonyms().end(); ++synonym)
          if (InStr(*synonym, *it, 0, true) > -1) found = true;
      if (!found) return false;
    }
  }

  // Item passed all filters
  return true;
}
示例#6
0
文件: list.cpp 项目: Hydro8182/taiga
int SortAsFileSize(LPCWSTR str1, LPCWSTR str2) {
  UINT64 size[2] = {1, 1};

  for (size_t i = 0; i < 2; i++) {
    std::wstring value = i == 0 ? str1 : str2;
    std::wstring unit;

    TrimRight(value, L".\r");
    EraseChars(value, L" ");

    if (value.length() >= 2) {
      for (auto it = value.rbegin(); it != value.rend(); ++it) {
        if (IsNumericChar(*it))
          break;
        unit.insert(unit.begin(), *it);
      }
      value.resize(value.length() - unit.length());
      Trim(unit);
    }

    int index = InStr(value, L".");
    if (index > -1) {
      int length = value.substr(index + 1).length();
      if (length <= 2)
        value.append(2 - length, '0');
      EraseChars(value, L".");
    } else {
      value.append(2, '0');
    }

    if (IsEqual(unit, L"KB")) {
      size[i] *= 1000;
    } else if (IsEqual(unit, L"KiB")) {
      size[i] *= 1024;
    } else if (IsEqual(unit, L"MB")) {
      size[i] *= 1000 * 1000;
    } else if (IsEqual(unit, L"MiB")) {
      size[i] *= 1024 * 1024;
    } else if (IsEqual(unit, L"GB")) {
      size[i] *= 1000 * 1000 * 1000;
    } else if (IsEqual(unit, L"GiB")) {
      size[i] *= 1024 * 1024 * 1024;
    }

    size[i] *= _wtoi(value.c_str());
  }

  return CompareValues<UINT64>(size[0], size[1]);
}
示例#7
0
// Read the lang.config file
bool LoadLangConfig(wchar_t *filename, char *str, UINT str_size)
{
	BUF *b;
	bool ret = false;
	// Validate arguments
	if (filename == NULL || str == NULL)
	{
		return false;
	}

	b = ReadDumpW(filename);
	if (b == NULL)
	{
		return false;
	}

	while (true)
	{
		char *line = CfgReadNextLine(b);

		if (line == NULL)
		{
			break;
		}

		Trim(line);

		if (IsEmptyStr(line) == false)
		{
			if (StartWith(line, "#") == false && StartWith(line, "//") == false && StartWith(line, ";") == false &&
				InStr(line, "#") == false)
			{
				StrCpy(str, str_size, line);
				ret = true;
			}
		}

		Free(line);
	}

	FreeBuf(b);

	return ret;
}
示例#8
0
void MediaPlayers::EditTitle(wstring& str, int player_index) {
    if (str.empty() || items[player_index].edits.empty()) return;

    for (unsigned int i = 0; i < items[player_index].edits.size(); i++) {
        switch (items[player_index].edits[i].mode) {
        // Erase
        case 1: {
            Replace(str, items[player_index].edits[i].value, L"", false, true);
            break;
        }
        // Cut right side
        case 2: {
            int pos = InStr(str, items[player_index].edits[i].value, 0);
            if (pos > -1) str.resize(pos);
            break;
        }
        }
    }

    TrimRight(str, L" -");
}
示例#9
0
/*
 * Compile the terminal capabilities for a display.
 * Input: tgetent(, D_termname) extra_incap, extra_outcap.
 * Effect: display initialisation.
 */
int InitTermcap(int width, int height)
{
	char *s;
	int i;
	char tbuf[TERMCAP_BUFSIZE], *tp;
	int t, xue, xse, xme;

	memset(tbuf, 0, sizeof(tbuf));
	if (*D_termname == 0 || e_tgetent(tbuf, D_termname) != 1) {
		Msg(0, "Cannot find terminfo entry for '%s'.", D_termname);
		return -1;
	}

	if ((D_tentry = malloc(TERMCAP_BUFSIZE + (extra_incap ? strlen(extra_incap) + 1 : 0))) == 0) {
		Msg(0, "%s", strnomem);
		return -1;
	}

	/*
	 * loop through all needed capabilities, record their values in the display
	 */
	tp = D_tentry;
	for (i = 0; i < T_N; i++) {
		switch (term[i].type) {
		case T_FLG:
			D_tcs[i].flg = e_tgetflag(term[i].tcname);
			break;
		case T_NUM:
			D_tcs[i].num = e_tgetnum(term[i].tcname);
			break;
		case T_STR:
			D_tcs[i].str = e_tgetstr(term[i].tcname, &tp);
			/* no empty strings, please */
			if (D_tcs[i].str && *D_tcs[i].str == 0)
				D_tcs[i].str = 0;
			break;
		default:
			Panic(0, "Illegal tc type in entry #%d", i);
		 /*NOTREACHED*/}
	}

	/*
	 * Now a good deal of sanity checks on the retrieved capabilities.
	 */
	if (D_HC) {
		Msg(0, "You can't run screen on a hardcopy terminal.");
		return -1;
	}
	if (D_OS) {
		Msg(0, "You can't run screen on a terminal that overstrikes.");
		return -1;
	}
	if (!D_CL) {
		Msg(0, "Clear screen capability required.");
		return -1;
	}
	if (!D_CM) {
		Msg(0, "Addressable cursor capability required.");
		return -1;
	}
	if ((s = getenv("COLUMNS")) && (i = atoi(s)) > 0)
		D_CO = i;
	if ((s = getenv("LINES")) && (i = atoi(s)) > 0)
		D_LI = i;
	if (width)
		D_CO = width;
	if (height)
		D_LI = height;
	if (D_CO <= 0)
		D_CO = 80;
	if (D_LI <= 0)
		D_LI = 24;

	if (D_CTF) {
		/* standard fixes for xterms etc */
		/* assume color for everything that looks ansi-compatible */
		if (!D_CAF && D_ME && (InStr(D_ME, "\033[m") || InStr(D_ME, "\033[0m"))) {
			D_CAF = "\033[3%p1%dm";
			D_CAB = "\033[4%p1%dm";
		}
		if (D_OP && InStr(D_OP, "\033[39;49m"))
			D_CAX = 1;
		if (D_OP && (InStr(D_OP, "\033[m") || InStr(D_OP, "\033[0m")))
			D_OP = 0;
		/* ISO2022 */
		if ((D_EA && InStr(D_EA, "\033(B")) || (D_AS && InStr(D_AS, "\033(0")))
			D_CG0 = 1;
		if (InStr(D_termname, "xterm") || InStr(D_termname, "rxvt") || (D_CKM && InStr(D_CKM, "\033[M")))
			D_CXT = 1;
		/* "be" seems to be standard for xterms... */
		if (D_CXT)
			D_BE = 1;
	}
	if (nwin_options.flowflag == nwin_undef.flowflag)
		nwin_default.flowflag = D_CNF ? FLOW_OFF : D_NX ? FLOW_ON : FLOW_AUTOFLAG;
	D_CLP |= (!D_AM || D_XV || D_XN);
	if (!D_BL)
		D_BL = "\007";
	if (!D_BC) {
		if (D_BS)
			D_BC = "\b";
		else
			D_BC = D_LE;
	}
	if (!D_CR)
		D_CR = "\r";
	if (!D_NL)
		D_NL = "\n";

	/*
	 *  Set up attribute handling.
	 *  This is rather complicated because termcap has different
	 *  attribute groups.
	 */

	if (D_UG > 0)
		D_US = D_UE = 0;
	if (D_SG > 0)
		D_SO = D_SE = 0;
	/* Unfortunately there is no 'mg' capability.
	 * For now we think that mg > 0 if sg and ug > 0.
	 */
	if (D_UG > 0 && D_SG > 0)
		D_MH = D_MD = D_MR = D_MB = D_ME = 0;

	xue = ATYP_U;
	xse = ATYP_S;
	xme = ATYP_M;

	if (D_SO && D_SE == 0) {
		Msg(0, "Warning: 'so' but no 'se' capability.");
		if (D_ME)
			xse = xme;
		else
			D_SO = 0;
	}
	if (D_US && D_UE == 0) {
		Msg(0, "Warning: 'us' but no 'ue' capability.");
		if (D_ME)
			xue = xme;
		else
			D_US = 0;
	}
	if ((D_MH || D_MD || D_MR || D_MB) && D_ME == 0) {
		Msg(0, "Warning: 'm?' but no 'me' capability.");
		D_MH = D_MD = D_MR = D_MB = 0;
	}
	/*
	 * Does ME also reverse the effect of SO and/or US?  This is not
	 * clearly specified by the termcap manual. Anyway, we should at
	 * least look whether ME and SE/UE are equal:
	 */
	if (D_UE && D_SE && strcmp(D_SE, D_UE) == 0)
		xse = xue;
	if (D_SE && D_ME && strcmp(D_ME, D_SE) == 0)
		xse = xme;
	if (D_UE && D_ME && strcmp(D_ME, D_UE) == 0)
		xue = xme;

	for (i = 0; i < NATTR; i++) {
		D_attrtab[i] = D_tcs[T_ATTR + i].str;
		D_attrtyp[i] = i == ATTR_SO ? xse : (i == ATTR_US ? xue : xme);
	}

	/* Set up missing entries (attributes are priority ordered) */
	s = 0;
	t = 0;
	for (i = 0; i < NATTR; i++)
		if ((s = D_attrtab[i])) {
			t = D_attrtyp[i];
			break;
		}
	for (i = 0; i < NATTR; i++) {
		if (D_attrtab[i] == 0) {
			D_attrtab[i] = s;
			D_attrtyp[i] = t;
		} else {
			s = D_attrtab[i];
			t = D_attrtyp[i];
		}
	}
	if (D_CAF || D_CAB || D_CSF || D_CSB)
		D_hascolor = 1;
	if (D_UT)
		D_BE = 1;	/* screen erased with background color */

	if (!D_DO)
		D_DO = D_NL;
	if (!D_SF)
		D_SF = D_NL;
	if (D_IN)
		D_IC = D_IM = 0;
	if (D_EI == 0)
		D_IM = 0;
	/* some strange termcap entries have IC == IM */
	if (D_IC && D_IM && strcmp(D_IC, D_IM) == 0)
		D_IC = 0;
	if (D_KE == 0)
		D_KS = 0;
	if (D_CVN == 0)
		D_CVR = 0;
	if (D_VE == 0)
		D_VI = D_VS = 0;
	if (D_CCE == 0)
		D_CCS = 0;

	if (D_CG0) {
		if (D_CS0 == 0)
			D_CS0 = "\033(%p1%c";
		if (D_CE0 == 0)
			D_CE0 = "\033(B";
		D_AC = 0;
		D_EA = 0;
	} else if (D_AC || (D_AS && D_AE)) {	/* some kind of graphics */
		D_CS0 = (D_AS && D_AE) ? D_AS : "";
		D_CE0 = (D_AS && D_AE) ? D_AE : "";
		D_CC0 = D_AC;
	} else {
		D_CS0 = D_CE0 = "";
		D_CC0 = 0;
		D_AC = "";	/* enable default string */
	}

	for (i = 0; i < 256; i++)
		D_c0_tab[i] = i;
	if (D_AC) {
		/* init with default string first */
		s = "l+m+k+j+u+t+v+w+q-x|n+o~s_p\"r#`+a:f'g#~o.v-^+<,>h#I#0#y<z>";
		for (i = (strlen(s) - 2) & ~1; i >= 0; i -= 2)
			D_c0_tab[(int)(unsigned char)s[i]] = s[i + 1];
	}
	if (D_CC0)
		for (i = (strlen(D_CC0) - 2) & ~1; i >= 0; i -= 2)
			D_c0_tab[(int)(unsigned char)D_CC0[i]] = D_CC0[i + 1];
	if (D_PF == 0)
		D_PO = 0;

	if (D_CXC)
		if (CreateTransTable(D_CXC))
			return -1;

	/* Termcap fields Z0 & Z1 contain width-changing sequences. */
	if (D_CZ1 == 0)
		D_CZ0 = 0;

	CheckScreenSize(0);

	if (D_TS == 0 || D_FS == 0 || D_DS == 0)
		D_HS = 0;
	if (D_HS) {
		if (D_WS < 0)
			D_WS = 0;
	}
	D_has_hstatus = hardstatusemu & ~HSTATUS_ALWAYS;
	if (D_HS && !(hardstatusemu & HSTATUS_ALWAYS))
		D_has_hstatus = HSTATUS_HS;

	if (D_CKJ) {
		int enc = FindEncoding(D_CKJ);
		if (enc != -1)
			D_encoding = enc;
	}
	if (!D_tcs[T_NAVIGATE].str && D_tcs[T_NAVIGATE + 1].str)
		D_tcs[T_NAVIGATE].str = D_tcs[T_NAVIGATE + 1].str;	/* kh = @1 */
	if (!D_tcs[T_NAVIGATE + 2].str && D_tcs[T_NAVIGATE + 3].str)
		D_tcs[T_NAVIGATE + 2].str = D_tcs[T_NAVIGATE + 3].str;	/* kH = @7 */

	D_UPcost = CalcCost(D_UP);
	D_DOcost = CalcCost(D_DO);
	D_NLcost = CalcCost(D_NL);
	D_LEcost = CalcCost(D_BC);
	D_NDcost = CalcCost(D_ND);
	D_CRcost = CalcCost(D_CR);
	D_IMcost = CalcCost(D_IM);
	D_EIcost = CalcCost(D_EI);

	if (D_CAN) {
		D_auto_nuke = true;
	}
	if (D_COL > 0) {
		D_obufmax = D_COL;
		D_obuflenmax = D_obuflen - D_obufmax;
	}

	/* Some xterm entries set F0 and F10 to the same string. Nuke F0. */
	if (D_tcs[T_CAPS].str && D_tcs[T_CAPS + 10].str && !strcmp(D_tcs[T_CAPS].str, D_tcs[T_CAPS + 10].str))
		D_tcs[T_CAPS].str = 0;
	/* Some xterm entries set kD to ^?. Nuke it. */
	if (D_tcs[T_NAVIGATE_DELETE].str && !strcmp(D_tcs[T_NAVIGATE_DELETE].str, "\0177"))
		D_tcs[T_NAVIGATE_DELETE].str = 0;
	/* wyse52 entries have kcub1 == kb == ^H. Nuke... */
	if (D_tcs[T_CURSOR + 3].str && !strcmp(D_tcs[T_CURSOR + 3].str, "\008"))
		D_tcs[T_CURSOR + 3].str = 0;

	D_nseqs = 0;
	for (i = 0; i < T_OCAPS - T_CAPS; i++)
		remap(i, 1);
	for (i = 0; i < kmap_extn; i++)
		remap(i + (KMAP_KEYS + KMAP_AKEYS), 1);
	D_seqp = D_kmaps + 3;
	D_seql = 0;
	D_seqh = 0;

	D_tcinited = 1;
	MakeTermcap(0);
	CheckEscape();
	return 0;
}
示例#10
0
fresult OpenSpaceStatusBar::SetTitle( char* szTitle, char* szSubtitle )
{
	fresult fres;
	//get max line length
	sword_t titleLen = Length(szTitle);

	sword_t subtitleCrPos = -1;
	subtitleCrPos = InStr(szSubtitle, "\n", 0);
	sword_t subtitleLen = 0;
	ubyte_t subtitleLines = 0;

	if (subtitleCrPos == -1)
	{
		subtitleLen = Length(szSubtitle);
		subtitleLines = 1;
	}
	else
	{
		sword_t line1Len = subtitleCrPos;
		sword_t line2Len = Length(szSubtitle) - subtitleCrPos;

		subtitleLen = line1Len > line2Len?line1Len:line2Len;
		subtitleLines = 2;
	}

	FAILIF(titleLen+subtitleLen > MAX_HEADER_TOTAL_LEN);

	//get tf
	TextFormat* tf = NULL;
	fres =_Repositories->TextFormats->GetTextFormat(TF_HEADER, &tf);
	ENSURESUCCESS(fres);

	Size statusSz = _pnlBasePanel->GetSize();


	//Positioning subtitle
	ubyte_t subtitleWidth = subtitleLen*tf->Font.GlyphSize.Width;
	Size sz ;
	sz.Width = subtitleWidth;


	ubyte_t titleOriginTop = statusSz.Height/2;
	ubyte_t titleOriginOffset = 0;
	if (subtitleLines ==1)
	{
		titleOriginOffset = (tf->Font.GlyphSize.Height)/2;
		sz.Height = tf->Font.GlyphSize.Height;
	}
	else
	{
		titleOriginOffset = tf->Font.GlyphSize.Height;
		sz.Height = tf->Font.GlyphSize.Height*2;
	}

	fres = _txtSubtitle->SetSize(sz);
	ENSURESUCCESS(fres);

	Position pos;
	pos.Left = _Size.Width - sz.Width-1;

	pos.Top = titleOriginTop - titleOriginOffset;

	fres = _txtSubtitle->SetPosition(pos);
	ENSURESUCCESS(fres);

	fres = _txtSubtitle->SetText(szSubtitle);
	ENSURESUCCESS(fres);
	
	//Positioning title
	subtitleWidth = subtitleLen*tf->Font.GlyphSize.Width;
	sz.Width = titleLen*tf->Font.GlyphSize.Width;
	sz.Height = tf->Font.GlyphSize.Height;
	fres = _txtHeader->SetSize(sz);
	ENSURESUCCESS(fres);

	pos = _txtHeader->GetPosition();
	pos.Left = SCREENX - sz.Width - subtitleWidth-2;
	pos.Top = titleOriginTop - tf->Font.GlyphSize.Height/2;

	fres = _txtHeader->SetPosition(pos);
	
	fres = _txtHeader->SetText(szTitle);
	ENSURESUCCESS(fres);

	fres = Draw();
	ENSURESUCCESS(fres);

	return SUCCESS;
}
示例#11
0
void SuDeleteGarbageInfsInner()
{
    char *base_key_name = "DRIVERS\\DriverDatabase\\DriverPackages";
    TOKEN_LIST *keys;
    HINSTANCE hSetupApiDll = NULL;
    BOOL (WINAPI *_SetupUninstallOEMInfA)(PCSTR, DWORD, PVOID) = NULL;

    if (MsIsWindows10() == false)
    {
        return;
    }

    hSetupApiDll = LoadLibraryA("setupapi.dll");
    if (hSetupApiDll == NULL)
    {
        return;
    }

    _SetupUninstallOEMInfA =
        (UINT (__stdcall *)(PCSTR,DWORD,PVOID))
        GetProcAddress(hSetupApiDll, "SetupUninstallOEMInfA");

    if (_SetupUninstallOEMInfA != NULL)
    {
        keys = MsRegEnumKeyEx2(REG_LOCAL_MACHINE, base_key_name, false, true);

        if (keys != NULL)
        {
            char full_key[MAX_PATH];
            UINT i;

            for (i = 0; i < keys->NumTokens; i++)
            {
                char *oem_name, *inf_name, *provider;

                Format(full_key, sizeof(full_key), "%s\\%s", base_key_name, keys->Token[i]);

                oem_name = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "", false, true);
                inf_name = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "InfName", false, true);
                provider = MsRegReadStrEx2(REG_LOCAL_MACHINE, full_key, "Provider", false, true);

                if (IsEmptyStr(oem_name) == false && IsEmptyStr(inf_name) == false)
                {
                    if (StartWith(oem_name, "oem"))
                    {
                        if (StartWith(inf_name, "selow"))
                        {
                            if (InStr(provider, "softether"))
                            {
                                Debug("Delete OEM INF %s (%s): %u\n",
                                      oem_name, inf_name,
                                      _SetupUninstallOEMInfA(oem_name, 0x00000001, NULL));
                            }
                        }
                    }
                }

                Free(oem_name);
                Free(inf_name);
                Free(provider);
            }

            FreeToken(keys);
        }
    }

    if (hSetupApiDll != NULL)
    {
        FreeLibrary(hSetupApiDll);
    }
}
示例#12
0
void TorrentDialog::RefreshList() {
  if (!IsWindow()) return;
  Feed* feed = Aggregator.Get(kFeedCategoryLink);
  if (!feed)
    return;

  // Disable drawing
  list_.SetRedraw(FALSE);

  // Clear list
  list_.DeleteAllItems();

  // Add items
  for (auto it = feed->items.begin(); it != feed->items.end(); ++it) {
    // Skip item if it was discarded and hidden
    if (it->state == kFeedItemDiscardedHidden)
      continue;

    std::wstring title, number, video;
    int group = kTorrentCategoryAnime;
    int icon = StatusToIcon(anime::kUnknownStatus);
    if (it->category == L"Batch" ||
        InStr(it->title, L"Vol.") > -1) {
      group = kTorrentCategoryBatch;
    }
    if (!IsNumeric(it->episode_data.number)) {
      if (it->episode_data.format.empty() ||
          anime::IsEpisodeRange(it->episode_data.number)) {
        group = kTorrentCategoryBatch;
      } else {
        group = kTorrentCategoryOther;
      }
    }
    auto anime_item = AnimeDatabase.FindItem(it->episode_data.anime_id);
    if (anime_item) {
      icon = StatusToIcon(anime_item->GetAiringStatus());
      title = anime_item->GetTitle();
    } else if (!it->episode_data.title.empty()) {
      title = it->episode_data.title;
    } else {
      group = kTorrentCategoryOther;
      title = it->title;
    }
    std::vector<int> numbers;
    anime::SplitEpisodeNumbers(it->episode_data.number, numbers);
    number = anime::JoinEpisodeNumbers(numbers);
    if (!it->episode_data.version.empty()) {
      number += L"v" + it->episode_data.version;
    }
    video = it->episode_data.video_type;
    if (!it->episode_data.resolution.empty()) {
      if (!video.empty()) video += L" ";
      video += it->episode_data.resolution;
    }
    int index = list_.InsertItem(it - feed->items.begin(),
                                 group, icon, 0, NULL, title.c_str(),
                                 reinterpret_cast<LPARAM>(&(*it)));
    list_.SetItem(index, 1, number.c_str());
    list_.SetItem(index, 2, it->episode_data.group.c_str());
    list_.SetItem(index, 3, it->episode_data.file_size.c_str());
    list_.SetItem(index, 4, video.c_str());
    list_.SetItem(index, 5, it->description.c_str());
    list_.SetItem(index, 6, it->episode_data.file.c_str());
    list_.SetCheckState(index, it->state == kFeedItemSelected);
  }

  // Redraw
  list_.SetRedraw(TRUE);
  list_.RedrawWindow(nullptr, nullptr,
                     RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN);
}
示例#13
0
// Get the version information of Windows
void Win32GetWinVer(RPC_WINVER *v)
{
	// Validate arguments
	if (v == NULL)
	{
		return;
	}

	Zero(v, sizeof(RPC_WINVER));

	v->IsWindows = true;

	if (OS_IS_WINDOWS_NT(GetOsType()) == false)
	{
		// Windows 9x
		OSVERSIONINFO os;
		Zero(&os, sizeof(os));
		os.dwOSVersionInfoSize = sizeof(os);
		GetVersionEx(&os);

		v->Build = LOWORD(os.dwBuildNumber);
		v->VerMajor = os.dwMajorVersion;
		v->VerMinor = os.dwMinorVersion;

		Format(v->Title, sizeof(v->Title), "%s %s",
			GetOsInfo()->OsProductName,
			GetOsInfo()->OsVersion);
		Trim(v->Title);
	}
	else
	{
		// Windows NT 4.0 SP6 or later
		OSVERSIONINFOEX os;
		Zero(&os, sizeof(os));
		os.dwOSVersionInfoSize = sizeof(os);
		Win32GetVersionExInternal((LPOSVERSIONINFOA)&os);

		v->IsNT = true;
		v->Build = os.dwBuildNumber;
		v->ServicePack = os.wServicePackMajor;

		if (os.wProductType != VER_NT_WORKSTATION)
		{
			v->IsServer = true;
		}
		v->VerMajor = os.dwMajorVersion;
		v->VerMinor = os.dwMinorVersion;

		if (GetOsInfo()->OsServicePack == 0)
		{
			StrCpy(v->Title, sizeof(v->Title), GetOsInfo()->OsProductName);
		}
		else
		{
			Format(v->Title, sizeof(v->Title), "%s Service Pack %u",
				GetOsInfo()->OsProductName,
				GetOsInfo()->OsServicePack);
		}
		Trim(v->Title);

		if (InStr(GetOsInfo()->OsVersion, "rc") ||
			InStr(GetOsInfo()->OsVersion, "beta"))
		{
			v->IsBeta = true;
		}
	}
}
示例#14
0
TOKEN_LIST *GetEthListEx(UINT *total_num_including_hidden)
{
	TOKEN_LIST *ret;
	UINT i;
	UINT j;
	UINT dummy_int;
	MS_ADAPTER_LIST *adapter_list;

	if (IsEthSupported() == false)
	{
		return NULL;
	}

	if (total_num_including_hidden == NULL)
	{
		total_num_including_hidden = &dummy_int;
	}

	*total_num_including_hidden = 0;

	Lock(eth_list_lock);

	InitEthAdaptersList();

	adapter_list = MsCreateAdapterList();

	ret = ZeroMalloc(sizeof(TOKEN_LIST));
	ret->NumTokens = LIST_NUM(eth_list);
	ret->Token = ZeroMalloc(sizeof(char *) * ret->NumTokens);
	j = 0;
	for (i = 0;i < ret->NumTokens;i++)
	{
		char tmp[MAX_SIZE];
		WP_ADAPTER *a = LIST_DATA(eth_list, i);
		MS_ADAPTER *msa = NULL;
		bool show = true;

		if (Win32EthGetShowAllIf() == false)
		{
			msa = MsGetAdapterByGuidFromList(adapter_list, a->Guid);

			if (InStr(a->Title, "vpn client adapter"))
			{
				// Hide virtual NIC for VPN client
				show = false;
			}

			if (InStr(a->Title, "tunnel adapter"))
			{
				// Hide tunnel adapter
				show = false;
			}

			if (InStr(a->Title, "teredo tunnel"))
			{
				// Hide tunnel adapter
				show = false;
			}

			if (InStr(a->Title, "MS Tunnel Interface"))
			{
				// Hide tunnel adapter
				show = false;
			}

			if (InStr(a->Title, "pseudo-interface"))
			{
				// Hide tunnel adapter
				show = false;
			}
		}

		if (msa != NULL)
		{
			// Hide except physical Ethernet NIC
			if (msa->IsNotEthernetLan)
			{
				show = false;
			}

			MsFreeAdapter(msa);
		}

		Win32EthMakeCombinedName(tmp, sizeof(tmp), a->Title, a->Guid);

		if (show)
		{
			ret->Token[j++] = CopyStr(tmp);

			Debug("%s - %s\n", a->Guid, a->Title);
		}
	}

	*total_num_including_hidden = ret->NumTokens;

	ret->NumTokens = j;

	Unlock(eth_list_lock);

	MsFreeAdapterList(adapter_list);

	return ret;
}
示例#15
0
void TorrentDialog::RefreshList() {
  if (!IsWindow()) return;
  Feed* feed = Aggregator.Get(FEED_CATEGORY_LINK);
  if (!feed) return;
  
  // Hide list to avoid visual defects and gain performance
  list_.Hide();
  list_.DeleteAllItems();

  // Add items
  for (auto it = feed->items.begin(); it != feed->items.end(); ++it) {
    // Skip item if it was discarded and hidden
    if (it->state == FEEDITEM_DISCARDED_HIDDEN)
      continue;

    wstring title, number, video;
    int group = TORRENT_ANIME, icon = StatusToIcon(0);
    if (it->category == L"Batch" ||
        InStr(it->title, L"Vol.") > -1) {
      group = TORRENT_BATCH;
    }
    if (!IsNumeric(it->episode_data.number)) {
      if (it->episode_data.format.empty() ||
          IsEpisodeRange(it->episode_data.number)) {
        group = TORRENT_BATCH;
      } else {
        group = TORRENT_OTHER;
      }
    }
    auto anime_item = AnimeDatabase.FindItem(it->episode_data.anime_id);
    if (anime_item) {
      icon = StatusToIcon(anime_item->GetAiringStatus());
      title = anime_item->GetTitle();
    } else if (!it->episode_data.title.empty()) {
      title = it->episode_data.title;
    } else {
      group = TORRENT_OTHER;
      title = it->title;
    }
    vector<int> numbers;
    SplitEpisodeNumbers(it->episode_data.number, numbers);
    number = JoinEpisodeNumbers(numbers);
    if (!it->episode_data.version.empty()) {
      number += L"v" + it->episode_data.version;
    }
    video = it->episode_data.video_type;
    if (!it->episode_data.resolution.empty()) {
      if (!video.empty()) video += L" ";
      video += it->episode_data.resolution;
    }
    int index = list_.InsertItem(it - feed->items.begin(),
                                 group, icon, 0, NULL, title.c_str(),
                                 reinterpret_cast<LPARAM>(&(*it)));
    list_.SetItem(index, 1, number.c_str());
    list_.SetItem(index, 2, it->episode_data.group.c_str());
    list_.SetItem(index, 3, it->episode_data.file_size.c_str());
    list_.SetItem(index, 4, video.c_str());
    list_.SetItem(index, 5, it->description.c_str());
    list_.SetItem(index, 6, it->episode_data.file.c_str());
    list_.SetCheckState(index, it->state == FEEDITEM_SELECTED);
  }

  // Show again
  list_.Show();

  // Set title
  wstring title = L"Torrents";
  if (!feed->title.empty()) {
    title = feed->title;
  } else if (!feed->link.empty()) {
    win32::Url url(feed->link);
    title += L" (" + url.Host + L")";
  }
  if (!feed->description.empty()) {
    title += L" - " + feed->description;
  }
  SetText(title.c_str());
}
示例#16
0
wstring MediaPlayers::GetTitleFromBrowser(HWND hwnd) {
    int stream_provider = STREAM_UNKNOWN;
    int web_engine = WEBENGINE_UNKNOWN;

    // Get window title
    wstring title = GetWindowTitle(hwnd);
    EditTitle(title, index);

    // Return current title if the same web page is still open
    if (CurrentEpisode.anime_id > 0)
        if (InStr(title, current_title) > -1)
            return current_title;

    // Delay operation to save some CPU
    static int counter = 0;
    if (counter < 5) {
        counter++;
        return current_title;
    } else {
        counter = 0;
    }

    // Select web browser engine
    if (items.at(index).engine == L"WebKit") {
        web_engine = WEBENGINE_WEBKIT;
    } else if (items.at(index).engine == L"Gecko") {
        web_engine = WEBENGINE_GECKO;
    } else if (items.at(index).engine == L"Trident") {
        web_engine = WEBENGINE_TRIDENT;
    } else if (items.at(index).engine == L"Presto") {
        web_engine = WEBENGINE_PRESTO;
    } else {
        return L"";
    }

    // Build accessibility data
    acc_obj.children.clear();
    if (acc_obj.FromWindow(hwnd) == S_OK) {
        acc_obj.BuildChildren(acc_obj.children, nullptr, web_engine);
        acc_obj.Release();
    }

    // Check other tabs
    if (CurrentEpisode.anime_id > 0) {
        AccessibleChild* child = nullptr;
        switch (web_engine) {
        case WEBENGINE_WEBKIT:
        case WEBENGINE_GECKO:
            child = FindAccessibleChild(acc_obj.children, L"", L"page tab list");
            break;
        case WEBENGINE_TRIDENT:
            child = FindAccessibleChild(acc_obj.children, L"Tab Row", L"");
            break;
        case WEBENGINE_PRESTO:
            child = FindAccessibleChild(acc_obj.children, L"", L"client");
            break;
        }
        if (child) {
            for (auto it = child->children.begin(); it != child->children.end(); ++it) {
                if (InStr(it->name, current_title) > -1) {
                    // Tab is still open, just not active
                    return current_title;
                }
            }
        }
        // Tab is closed
        return L"";
    }

    // Find URL
    AccessibleChild* child = nullptr;
    switch (web_engine) {
    case WEBENGINE_WEBKIT:
        child = FindAccessibleChild(acc_obj.children, L"Address and search bar", L"grouping");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Address", L"grouping");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Location", L"grouping");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Address field", L"editable text");
        break;
    case WEBENGINE_GECKO:
        child = FindAccessibleChild(acc_obj.children, L"Search or enter address", L"editable text");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Go to a Website", L"editable text");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Go to a Web Site", L"editable text");
        break;
    case WEBENGINE_TRIDENT:
        child = FindAccessibleChild(acc_obj.children, L"Address and search using Bing", L"editable text");
        if (child == nullptr)
            child = FindAccessibleChild(acc_obj.children, L"Address and search using Google", L"editable text");
        break;
    case WEBENGINE_PRESTO:
        child = FindAccessibleChild(acc_obj.children, L"", L"client");
        if (child && !child->children.empty()) {
            child = FindAccessibleChild(child->children.at(0).children, L"", L"tool bar");
            if (child && !child->children.empty()) {
                child = FindAccessibleChild(child->children, L"", L"combo box");
                if (child && !child->children.empty()) {
                    child = FindAccessibleChild(child->children, L"", L"editable text");
                }
            }
        }
        break;
    }

    // Check URL for known streaming video providers
    if (child) {
        // Anime News Network
        if (Settings.Recognition.Streaming.ann_enabled &&
                InStr(child->value, L"animenewsnetwork.com/video") > -1) {
            stream_provider = STREAM_ANN;
            // Crunchyroll
        } else if (Settings.Recognition.Streaming.crunchyroll_enabled &&
                   InStr(child->value, L"crunchyroll.com/") > -1) {
            stream_provider = STREAM_CRUNCHYROLL;
            // Hulu
            /*
            } else if (InStr(child->value, L"hulu.com/watch") > -1) {
              stream_provider = STREAM_HULU;
            */
            // Veoh
        } else if (Settings.Recognition.Streaming.veoh_enabled &&
                   InStr(child->value, L"veoh.com/watch") > -1) {
            stream_provider = STREAM_VEOH;
            // Viz Anime
        } else if (Settings.Recognition.Streaming.viz_enabled &&
                   InStr(child->value, L"vizanime.com/ep") > -1) {
            stream_provider = STREAM_VIZANIME;
            // YouTube
        } else if (Settings.Recognition.Streaming.youtube_enabled &&
                   InStr(child->value, L"youtube.com/watch") > -1) {
            stream_provider = STREAM_YOUTUBE;
        }
    }

    // Clean-up title
    switch (stream_provider) {
    // Anime News Network
    case STREAM_ANN:
        EraseRight(title, L" - Anime News Network");
        Erase(title, L" (s)");
        Erase(title, L" (d)");
        break;
    // Crunchyroll
    case STREAM_CRUNCHYROLL:
        EraseLeft(title, L"Crunchyroll - Watch ");
        break;
    // Hulu
    case STREAM_HULU:
        EraseLeft(title, L"Watch ");
        EraseRight(title, L" online | Free | Hulu");
        EraseRight(title, L" online | Plus | Hulu");
        break;
    // Veoh
    case STREAM_VEOH:
        EraseLeft(title, L"Watch Videos Online | ");
        EraseRight(title, L" | Veoh.com");
        break;
    // Viz Anime
    case STREAM_VIZANIME:
        EraseRight(title, L" - VIZ ANIME: Free Online Anime - All The Time");
        break;
    // YouTube
    case STREAM_YOUTUBE:
        EraseRight(title, L" - YouTube");
        break;
    // Some other website, or URL is not found
    case STREAM_UNKNOWN:
        title.clear();
        break;
    }

    return title;
}
示例#17
0
//*****************************************************************************
void CScreen::GetStr(int iX, int iY, char szAns[], int iLen, char szFmt[], bool bEcho)
{   // gets a string of iLen chars specified by fmt
	// fmt = @ - alpha, # - numeric, ~ - alpha/numeric, | - any key	
	char cLetter, *pTemp;
	int iCount = 0, iSize = iLen, iFmtSize = strlen(szFmt);
	bool bMem = false;

	if (iFmtSize != iLen)             // build more/less fmt string
	{
		pTemp = new char[iLen + 1];   // make fmt str to take anything
		strncpy(pTemp, szFmt, iLen);// copy original & add extra
		strncat(pTemp, "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
			, (iLen - iFmtSize<0) ? 0 : iLen - iFmtSize);
		pTemp[iLen] = 0;              // terminate the fmt string
		szFmt = pTemp;                // use szFmt to traverse
		bMem = true;                  // flag to delete at bottom
	}

	GotoXY(iX, iY);
	for (int iX1 = 0; iX1<iSize; iX1++)printf("_");// space holders for answer
	while (iCount < iSize + 1)                    // get string from KB
	{
		GotoXY(iX + iCount, iY); printf("%c", ' ');// blank out for new char
		GotoXY(iX + iCount, iY);                  // backup
		if (szFmt[iCount] == '#')                // get a #
		{
			while (!InStr((cLetter = _getch()), "0123456789.") && cLetter != '\b'
				&&cLetter != '\r')printf("\7");
			szAns[iCount] = cLetter;
		}
		else if (szFmt[iCount] == '@')          // get a letter
		{
			while (!InStr((cLetter = toupper(_getch())), "ABCDEFGHIJKLMNOPQRSTUVWXYZ ")
				&& cLetter != '\b'&&cLetter != '\r')printf("\7");
		}
		else if (szFmt[iCount] == '~')          // get a letter or #
		{
			while (!InStr((cLetter = toupper(_getch())), "0123456789.ABCDEFGHIJKLMNOPQRSTUVWXYZ ")
				&& cLetter != '\b'&&cLetter != '\r')printf("\7");
		}
		else if (szFmt[iCount] == '|')          // get any char
		{
			cLetter = _getch();
		}
		else if (szFmt[iCount] == 0)            // get a <CR>
		{
			while (((cLetter = toupper(_getch())) != '\r')
				&& cLetter != '\b')printf("\7");
		}
		else                                    // skip fmt letter
		{
			cLetter = szFmt[iCount];
		}

		if (cLetter == '\r')                    // if <CR> done
		{
			break;
		}
		if (cLetter == '\b')                    // if not backspace
		{
			while (iCount >0 && !InStr(szFmt[--iCount], "#@")); // back up
			continue;
		}
		else
		{
			szAns[iCount++] = cLetter;           // put it in string
			if (bEcho)
				printf("%c", cLetter);
			else
				printf("%c", '*');
		}
	}
	szAns[iCount] = 0;                            // terminate string
	if (bMem)
		delete[] pTemp;
	_flushall();
}
示例#18
0
bool EvaluateCondition(const FeedFilterCondition& condition,
                       const FeedItem& item) {
  bool is_numeric = false;
  std::wstring element;
  std::wstring value = ReplaceVariables(condition.value, item.episode_data);
  auto anime = AnimeDatabase.FindItem(item.episode_data.anime_id);

  switch (condition.element) {
    case kFeedFilterElement_File_Title:
      element = item.title;
      break;
    case kFeedFilterElement_File_Category:
      element = item.category;
      break;
    case kFeedFilterElement_File_Description:
      element = item.description;
      break;
    case kFeedFilterElement_File_Link:
      element = item.link;
      break;
    case kFeedFilterElement_Meta_Id:
      if (anime)
        element = ToWstr(anime->GetId());
      is_numeric = true;
      break;
    case kFeedFilterElement_Episode_Title:
      element = item.episode_data.title;
      break;
    case kFeedFilterElement_Meta_DateStart:
      if (anime)
        element = anime->GetDateStart();
      break;
    case kFeedFilterElement_Meta_DateEnd:
      if (anime)
        element = anime->GetDateEnd();
      break;
    case kFeedFilterElement_Meta_Episodes:
      if (anime)
        element = ToWstr(anime->GetEpisodeCount());
      is_numeric = true;
      break;
    case kFeedFilterElement_Meta_Status:
      if (anime)
        element = ToWstr(anime->GetAiringStatus());
      is_numeric = true;
      break;
    case kFeedFilterElement_Meta_Type:
      if (anime)
        element = ToWstr(anime->GetType());
      is_numeric = true;
      break;
    case kFeedFilterElement_User_Status:
      if (anime)
        element = ToWstr(anime->GetMyStatus());
      is_numeric = true;
      break;
    case kFeedFilterElement_Episode_Number:
      element = ToWstr(anime::GetEpisodeHigh(item.episode_data.number));
      is_numeric = true;
      break;
    case kFeedFilterElement_Episode_Version:
      element = item.episode_data.version;
      if (element.empty())
        element = L"1";
      is_numeric = true;
      break;
    case kFeedFilterElement_Local_EpisodeAvailable:
      if (anime)
        element = ToWstr(anime->IsEpisodeAvailable(
            anime::GetEpisodeHigh(item.episode_data.number)));
      is_numeric = true;
      break;
    case kFeedFilterElement_Episode_Group:
      element = item.episode_data.group;
      break;
    case kFeedFilterElement_Episode_VideoResolution:
      element = item.episode_data.resolution;
      break;
    case kFeedFilterElement_Episode_VideoType:
      element = item.episode_data.video_type;
      break;
  }

  switch (condition.op) {
    case kFeedFilterOperator_Equals:
      if (is_numeric) {
        if (IsEqual(value, L"True"))
          return ToInt(element) == TRUE;
        return ToInt(element) == ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) == anime::TranslateResolution(condition.value);
        } else {
          return IsEqual(element, value);
        }
      }
    case kFeedFilterOperator_NotEquals:
      if (is_numeric) {
        if (IsEqual(value, L"True"))
          return ToInt(element) == TRUE;
        return ToInt(element) != ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) != anime::TranslateResolution(condition.value);
        } else {
          return !IsEqual(element, value);
        }
      }
    case kFeedFilterOperator_IsGreaterThan:
      if (is_numeric) {
        return ToInt(element) > ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) > anime::TranslateResolution(condition.value);
        } else {
          return CompareStrings(element, condition.value) > 0;
        }
      }
    case kFeedFilterOperator_IsGreaterThanOrEqualTo:
      if (is_numeric) {
        return ToInt(element) >= ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) >= anime::TranslateResolution(condition.value);
        } else {
          return CompareStrings(element, condition.value) >= 0;
        }
      }
    case kFeedFilterOperator_IsLessThan:
      if (is_numeric) {
        return ToInt(element) < ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) < anime::TranslateResolution(condition.value);
        } else {
          return CompareStrings(element, condition.value) < 0;
        }
      }
    case kFeedFilterOperator_IsLessThanOrEqualTo:
      if (is_numeric) {
        return ToInt(element) <= ToInt(value);
      } else {
        if (condition.element == kFeedFilterElement_Episode_VideoResolution) {
          return anime::TranslateResolution(element) <= anime::TranslateResolution(condition.value);
        } else {
          return CompareStrings(element, condition.value) <= 0;
        }
      }
    case kFeedFilterOperator_BeginsWith:
      return StartsWith(element, value);
    case kFeedFilterOperator_EndsWith:
      return EndsWith(element, value);
    case kFeedFilterOperator_Contains:
      return InStr(element, value, 0, true) > -1;
    case kFeedFilterOperator_NotContains:
      return InStr(element, value, 0, true) == -1;
  }

  return false;
}