void CPicDowloadThread::GetLinkmanPicPath(LPTSTR tszPicName, int nSize,LPCTSTR lptUrl,  LPCTSTR lptFriendId)
{
//	GetFriendFacePicDir(tszPicName, MAX_PATH);
//  获取url后缀,即图片格式
// 	int len = _tcslen(lptUrl);
// 
// 	int suffixlen =0;
// 	LPCTSTR p;
// 
// 	for (p=lptUrl+len-1; p!=lptUrl; p--)
// 	{
// 		suffixlen++;
// 		if (*p == _T('.'))
// 		{
// 			break;
// 		}
// 	}
// 
// 	TCHAR* tstrSuff = new TCHAR[suffixlen+1];
// 	_tcscpy(tstrSuff,p);
	tString tstrUrl = lptUrl;
	EncodeUrl(tstrUrl);
	wsprintf(tszPicName, _T("%s\\[%s]#%s"), m_tszDir, lptFriendId, tstrUrl.c_str());

	//SAFE_ARRYDELETE(tstrSuff);
}
Exemple #2
0
bool Twitter::SetStatusText(const wstring& status_text) {
  if (Settings.Announce.Twitter.oauth_key.empty() || Settings.Announce.Twitter.oauth_secret.empty()) {
    return false;
  }
  if (status_text.empty() || status_text == status_text_) {
    return false;
  }
  status_text_ = status_text;

  OAuthParameters post_parameters;
  post_parameters[L"status"] = EncodeUrl(status_text_);

  wstring header = 
    Clients.sharing.twitter.GetDefaultHeader() + 
    oauth.BuildHeader(
      L"https://api.twitter.com/1.1/statuses/update.json", 
      L"POST", &post_parameters, 
      Settings.Announce.Twitter.oauth_key, 
      Settings.Announce.Twitter.oauth_secret);

  Clients.sharing.twitter.SetHttpsEnabled(TRUE);

  return Clients.sharing.twitter.Connect(
    L"api.twitter.com", L"1.1/statuses/update.json", 
    L"status=" + post_parameters[L"status"],
    L"POST", header, L"myanimelist.net", L"", 
    HTTP_Twitter_Post);
}
Exemple #3
0
std::wstring Url::Build() const {
  std::wstring url;

  switch (protocol) {
    case base::http::kHttp:
    default:
      url += L"http";
      break;
    case base::http::kHttps:
      url += L"https";
      break;
  }
  url += L"://";

  url += host;

  if (port > 0)
    url += L":" + ToWstr(port);

  url += path;

  if (!query.empty()) {
    std::wstring query_string;
    foreach_(it, query) {
      query_string += query_string.empty() ? L"?" : L"&";
      query_string += it->first + L"=" + EncodeUrl(it->second, false);
    }
Exemple #4
0
// 根据用户Id , URL获取当前用户pic的路径, 注意id中如果存在":", 替换成空格
void GetMemberPicPath(tString & tstrPath, LPCTSTR lptDir, LPCTSTR lptUrl, LPCTSTR lptId)
{
#if 0 // 根据url id 方式命名
	tString tstrUrl = lptUrl;
	EncodeUrl(tstrUrl);
	TCHAR tszId[30] = {0x0};
	tString tstrId = lptId;
	Replace(tstrId, _T(":"), _T(" "));
	TCHAR tszPicName[MAX_FILENAME_SIZE + 1] = {0x0};
	_stprintf_s(tszPicName, _T("%s\\[%s]#%s"), lptDir, tstrId.c_str(), tstrUrl.c_str());
	tstrPath  = tszPicName;
#endif 
	
	//tstrPath = _T("");
  LPCTSTR lptFind = _tcsrchr(lptUrl, _T('/')) ;

  if (lptFind != NULL)
  {
	  tString tstrId =  lptFind + 1;
	  Replace(tstrId, _T(":"), _T(" "));
	  TCHAR tszPicName[MAX_FILENAME_SIZE + 1] = {0x0};
	  _stprintf_s(tszPicName, _T("%s\\%s"), lptDir,tstrId.c_str() );
	  tstrPath = tszPicName;
  }
}
Exemple #5
0
bool CAttachmentProcessor::Upload(TRequest& request, TResponse& response)
{
	const TUploadConf* pUploadConf = request.pUploadConf;
	if(NULL == pUploadConf)
		return false;

	const vector<TFormFile>& files = request.files();
	vector<TFileResponse>& vecFileResponse = response.vecFileResponse;
	vecFileResponse.resize(files.size());

	int nSuccess = 0;
	for(size_t i=0; i<files.size(); i++){
		const TFormFile& formFile = files[i];
		TFileResponse& fileResponse = vecFileResponse[i];
		if(fileResponse.nCode != 1)
			continue;
		try{
			//获取路经
			vector<string> vecFilePath, vecDbPath;
			const string& strFileName = fileResponse.strFileName;
			size_t index = strFileName.find(".");
			string strExt;
			if(index != string::npos)
				strExt = strFileName.substr(index+1);
			//生成一次保存地址,只是简单保存下来
			GenerateSavePath(pUploadConf, strExt, vecDbPath, vecFilePath);

			//直接保存附件
			if(!SaveFile(vecFilePath[0], formFile.data)){
				fileResponse.nCode = 0;
				fileResponse.strMsg = "保存附件出错";
				continue;
			}

			fileResponse.nCode = 1;
			fileResponse.mapOtherMsg["url"] = vecDbPath[0];
			nSuccess++;
		}
		catch(Exception & e){
			fileResponse.nCode=0;
			fileResponse.strMsg = "处理附件出错";
			string strError=e.what();
			Log("UploadAttachmentFail %s %s", EncodeUrl(formFile.filename).c_str(), strError.c_str());
		}
	}
	response.nErrorCount = response.nTotalCount - nSuccess;
	if(nSuccess == 0){
		response.nCode = 0;
		response.strMsg = "所有附件处理失败";
		return false;
	}

	return true;
}
Exemple #6
0
void ExecuteAction(std::wstring action, WPARAM wParam, LPARAM lParam) {
  LOG(LevelDebug, action);

  std::wstring body;
  size_t pos = action.find('(');
  if (pos != action.npos) {
    body = action.substr(pos + 1, action.find_last_of(')') - (pos + 1));
    action.resize(pos);
  }
  Trim(body);
  Trim(action);
  if (action.empty())
    return;

  //////////////////////////////////////////////////////////////////////////////
  // Taiga

  // CheckUpdates()
  //   Checks for a new version of the program.
  if (action == L"CheckUpdates") {
    ui::ShowDialog(ui::kDialogUpdate);

  // Exit(), Quit()
  //   Exits from Taiga.
  } else if (action == L"Exit" || action == L"Quit") {
    ui::DlgMain.Destroy();

  //////////////////////////////////////////////////////////////////////////////
  // Services

  // Synchronize()
  //   Synchronizes local and remote lists.
  } else if (action == L"Synchronize") {
    sync::Synchronize();

  // SearchAnime()
  //   wParam is a BOOL value that defines local search.
  } else if (action == L"SearchAnime") {
    if (body.empty())
      return;
    bool local_search = wParam != FALSE;
    if (!local_search) {
      auto service = taiga::GetCurrentService();
      if (service->RequestNeedsAuthentication(sync::kSearchTitle)) {
        if (taiga::GetCurrentUsername().empty() ||
            taiga::GetCurrentPassword().empty()) {
          ui::OnSettingsAccountEmpty();
          return;
        }
      }
    }
    ui::DlgMain.navigation.SetCurrentPage(ui::kSidebarItemSearch);
    ui::DlgMain.edit.SetText(body);
    ui::DlgSearch.Search(body, local_search);

  // ViewAnimePage
  //   Opens up anime page on the active service.
  //   lParam is an anime ID.
  } else if (action == L"ViewAnimePage") {
    int anime_id = static_cast<int>(lParam);
    switch (taiga::GetCurrentServiceId()) {
      case sync::kMyAnimeList:
        sync::myanimelist::ViewAnimePage(anime_id);
        break;
      case sync::kHummingbird:
        sync::hummingbird::ViewAnimePage(anime_id);
        break;
    }

  // ViewUpcomingAnime
  //   Opens up upcoming anime page on MAL.
  } else if (action == L"ViewUpcomingAnime") {
    switch (taiga::GetCurrentServiceId()) {
      case sync::kMyAnimeList:
        sync::myanimelist::ViewUpcomingAnime();
        break;
      case sync::kHummingbird:
        sync::hummingbird::ViewUpcomingAnime();
        break;
    }

  // MalViewPanel()
  // MalViewProfile()
  // MalViewHistory()
  //   Opens up MyAnimeList user pages.
  } else if (action == L"MalViewPanel") {
    sync::myanimelist::ViewPanel();
  } else if (action == L"MalViewProfile") {
    sync::myanimelist::ViewProfile();
  } else if (action == L"MalViewHistory") {
    sync::myanimelist::ViewHistory();

  // HummingbirdViewProfile()
  // HummingbirdViewDashboard()
  // HummingbirdViewRecommendations()
  //   Opens up Hummingbird user pages.
  } else if (action == L"HummingbirdViewProfile") {
    sync::hummingbird::ViewProfile();
  } else if (action == L"HummingbirdViewDashboard") {
    sync::hummingbird::ViewDashboard();
  } else if (action == L"HummingbirdViewRecommendations") {
    sync::hummingbird::ViewRecommendations();

  //////////////////////////////////////////////////////////////////////////////

  // Execute(path)
  //   Executes a file or folder.
  } else if (action == L"Execute") {
    Execute(body);

  // URL(address)
  //   Opens a web page.
  //   lParam is an anime ID.
  } else if (action == L"URL") {
    int anime_id = static_cast<int>(lParam);
    auto anime_item = AnimeDatabase.FindItem(anime_id);
    if (anime_item) {
      std::wstring title = anime_item->GetTitle();
      ReplaceString(body, L"%title%", EncodeUrl(title));
    }
    ExecuteLink(body);

  //////////////////////////////////////////////////////////////////////////////
  // UI

  // About()
  //   Shows about window.
  } else if (action == L"About") {
    ui::ShowDialog(ui::kDialogAbout);

  // Info([anime_id])
  //   Shows anime information window.
  //   lParam is an anime ID.
  } else if (action == L"Info") {
    int anime_id = body.empty() ? static_cast<int>(lParam) : ToInt(body);
    ui::ShowDlgAnimeInfo(anime_id);

  // MainDialog()
  } else if (action == L"MainDialog") {
    ui::ShowDialog(ui::kDialogMain);

  // Settings()
  //   Shows settings window.
  //   wParam is the initial section.
  //   lParam is the initial page.
  } else if (action == L"Settings") {
    ui::ShowDlgSettings(wParam, lParam);

  // SearchTorrents(source)
  //   Searches torrents from specified source URL.
  //   lParam is an anime ID.
  } else if (action == L"SearchTorrents") {
    int anime_id = static_cast<int>(lParam);
    if (body.empty())
      body = Settings[taiga::kTorrent_Discovery_SearchUrl];
    ui::DlgTorrent.Search(body, anime_id);

  // ToggleSidebar()
  } else if (action == L"ToggleSidebar") {
    bool hide_sidebar = Settings.Toggle(taiga::kApp_Option_HideSidebar);
    ui::DlgMain.treeview.Show(!hide_sidebar);
    ui::DlgMain.UpdateControlPositions();
    ui::Menus.UpdateView();

  // TorrentAddFilter()
  //   Shows add new filter window.
  //   wParam is a BOOL value that represents modal status.
  //   lParam is the handle of the parent window.
  } else if (action == L"TorrentAddFilter") {
    if (!ui::DlgFeedFilter.IsWindow()) {
      ui::DlgFeedFilter.Create(IDD_FEED_FILTER,
          reinterpret_cast<HWND>(lParam), wParam != FALSE);
    } else {
      ActivateWindow(ui::DlgFeedFilter.GetWindowHandle());
    }

  // ViewContent(page)
  //   Selects a page from sidebar.
  } else if (action == L"ViewContent") {
    int page = ToInt(body);
    ui::DlgMain.navigation.SetCurrentPage(page);

  //////////////////////////////////////////////////////////////////////////////
  // Library

  // AddToList(status)
  //   Adds an anime to list with given status.
  //   wParam is a BOOL value that defines lParam.
  //   lParam is an anime ID, or a pointer to a vector of anime IDs.
  } else if (action == L"AddToList") {
    int status = ToInt(body);
    if (!wParam) {
      int anime_id = static_cast<int>(lParam);
      AnimeDatabase.AddToList(anime_id, status);
    } else {
      const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
      for (const auto& anime_id : anime_ids) {
        AnimeDatabase.AddToList(anime_id, status);
      }
    }

  // ClearHistory()
  //   Deletes all history items.
  } else if (action == L"ClearHistory") {
    if (ui::OnHistoryClear())
      History.Clear();

  //////////////////////////////////////////////////////////////////////////////
  // Tracker

  // AddFolder()
  //   Opens up a dialog to add new library folder.
  } else if (action == L"AddFolder") {
    std::wstring path;
    if (win::BrowseForFolder(ui::GetWindowHandle(ui::kDialogMain),
                             L"Add a Library Folder", L"", path)) {
      Settings.library_folders.push_back(path);
      if (Settings.GetBool(taiga::kLibrary_WatchFolders))
        FolderMonitor.Enable();
      ui::ShowDlgSettings(ui::kSettingsSectionLibrary, ui::kSettingsPageLibraryFolders);
    }

  // ScanEpisodes(), ScanEpisodesAll()
  //   Checks episode availability.
  } else if (action == L"ScanEpisodes") {
    int anime_id = static_cast<int>(lParam);
    ScanAvailableEpisodes(false, anime_id, 0);
  } else if (action == L"ScanEpisodesAll") {
    ScanAvailableEpisodes(false);

  //////////////////////////////////////////////////////////////////////////////
  // Settings

  // ToggleRecognition()
  //   Enables or disables anime recognition.
  } else if (action == L"ToggleRecognition") {
    bool enable_recognition = Settings.Toggle(taiga::kApp_Option_EnableRecognition);
    if (enable_recognition) {
      ui::ChangeStatusText(L"Automatic anime recognition is now enabled.");
      CurrentEpisode.Set(anime::ID_UNKNOWN);
    } else {
      ui::ChangeStatusText(L"Automatic anime recognition is now disabled.");
      auto anime_item = AnimeDatabase.FindItem(CurrentEpisode.anime_id);
      CurrentEpisode.Set(anime::ID_NOTINLIST);
      if (anime_item)
        EndWatching(*anime_item, CurrentEpisode);
    }

  // ToggleSharing()
  //   Enables or disables automatic sharing.
  } else if (action == L"ToggleSharing") {
    bool enable_sharing = Settings.Toggle(taiga::kApp_Option_EnableSharing);
    ui::Menus.UpdateTools();
    if (enable_sharing) {
      ui::ChangeStatusText(L"Automatic sharing is now enabled.");
    } else {
      ui::ChangeStatusText(L"Automatic sharing is now disabled.");
    }

  // ToggleSynchronization()
  //   Enables or disables automatic list synchronization.
  } else if (action == L"ToggleSynchronization") {
    bool enable_sync = Settings.Toggle(taiga::kApp_Option_EnableSync);
    ui::Menus.UpdateTools();
    if (enable_sync) {
      ui::ChangeStatusText(L"Automatic synchronization is now enabled.");
    } else {
      ui::ChangeStatusText(L"Automatic synchronization is now disabled.");
    }

  //////////////////////////////////////////////////////////////////////////////
  // Sharing

  // AnnounceToHTTP(force)
  //   Sends an HTTP request.
  } else if (action == L"AnnounceToHTTP") {
    Announcer.Do(taiga::kAnnounceToHttp, nullptr, body == L"true");

  // AnnounceToMIRC(force)
  //   Sends message to specified channels in mIRC.
  } else if (action == L"AnnounceToMIRC") {
    Announcer.Do(taiga::kAnnounceToMirc, nullptr, body == L"true");

  // AnnounceToSkype(force)
  //   Changes Skype mood text.
  //   Requires authorization.
  } else if (action == L"AnnounceToSkype") {
    Announcer.Do(taiga::kAnnounceToSkype, nullptr, body == L"true");

  // AnnounceToTwitter(force)
  //   Changes Twitter status.
  } else if (action == L"AnnounceToTwitter") {
    Announcer.Do(taiga::kAnnounceToTwitter, nullptr, body == L"true");

  //////////////////////////////////////////////////////////////////////////////

  // EditAll([anime_id])
  //   Shows a dialog to edit details of an anime.
  //   lParam is an anime ID.
  } else if (action == L"EditAll") {
    int anime_id = body.empty() ? static_cast<int>(lParam) : ToInt(body);
    ui::ShowDlgAnimeEdit(anime_id);

  // EditDelete()
  //   Removes an anime from list.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"EditDelete") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    if (ui::OnLibraryEntriesEditDelete(anime_ids)) {
      for (const auto& anime_id : anime_ids) {
        HistoryItem history_item;
        history_item.anime_id = anime_id;
        history_item.mode = taiga::kHttpServiceDeleteLibraryEntry;
        History.queue.Add(history_item);
      }
    }

  // EditEpisode()
  //   Changes watched episode value of an anime.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"EditEpisode") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    int value = ui::OnLibraryEntriesEditEpisode(anime_ids);
    if (value > -1) {
      for (const auto& anime_id : anime_ids) {
        anime::ChangeEpisode(anime_id, value);
      }
    }

  // DecrementEpisode()
  //   lParam is an anime ID.
  } else if (action == L"DecrementEpisode") {
    int anime_id = static_cast<int>(lParam);
    anime::DecrementEpisode(anime_id);
  // IncrementEpisode()
  //   lParam is an anime ID.
  } else if (action == L"IncrementEpisode") {
    int anime_id = static_cast<int>(lParam);
    anime::IncrementEpisode(anime_id);

  // EditScore(value)
  //   Changes anime score.
  //   Value must be between 0-10 and different from current score.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"EditScore") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    for (const auto& anime_id : anime_ids) {
      HistoryItem history_item;
      history_item.anime_id = anime_id;
      history_item.score = ToInt(body);
      history_item.mode = taiga::kHttpServiceUpdateLibraryEntry;
      History.queue.Add(history_item);
    }

  // EditStatus(value)
  //   Changes anime status of user.
  //   Value must be 1, 2, 3, 4 or 5, and different from current status.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"EditStatus") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    for (const auto& anime_id : anime_ids) {
      HistoryItem history_item;
      history_item.status = ToInt(body);
      auto anime_item = AnimeDatabase.FindItem(anime_id);
      if (!anime_item)
        continue;
      switch (*history_item.status) {
        case anime::kCompleted:
          history_item.episode = anime_item->GetEpisodeCount();
          if (*history_item.episode == 0)
            history_item.episode.Reset();
          if (!anime::IsValidDate(anime_item->GetMyDateStart()) &&
              anime_item->GetEpisodeCount() == 1)
              history_item.date_start = GetDate();
          if (!anime::IsValidDate(anime_item->GetMyDateEnd()))
            history_item.date_finish = GetDate();
          break;
      }
      history_item.anime_id = anime_id;
      history_item.mode = taiga::kHttpServiceUpdateLibraryEntry;
      History.queue.Add(history_item);
    }

  // EditTags(tags)
  //   Changes anime tags.
  //   Tags must be separated by a comma.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"EditTags") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    std::wstring tags;
    if (ui::OnLibraryEntriesEditTags(anime_ids, tags)) {
      for (const auto& anime_id : anime_ids) {
        HistoryItem history_item;
        history_item.anime_id = anime_id;
        history_item.tags = tags;
        history_item.mode = taiga::kHttpServiceUpdateLibraryEntry;
        History.queue.Add(history_item);
      }
    }

  //////////////////////////////////////////////////////////////////////////////

  // OpenFolder()
  //   Searches for anime folder and opens it.
  //   lParam is an anime ID.
  } else if (action == L"OpenFolder") {
    int anime_id = static_cast<int>(lParam);
    auto anime_item = AnimeDatabase.FindItem(anime_id);
    if (!anime_item || !anime_item->IsInList())
      return;
    if (!anime::ValidateFolder(*anime_item))
      ScanAvailableEpisodes(false, anime_item->GetId(), 0);
    if (anime_item->GetFolder().empty()) {
      if (ui::OnAnimeFolderNotFound()) {
        std::wstring default_path, path;
        if (!Settings.library_folders.empty())
          default_path = Settings.library_folders.front();
        if (win::BrowseForFolder(ui::GetWindowHandle(ui::kDialogMain),
                                 L"Select Anime Folder",
                                 default_path, path)) {
          anime_item->SetFolder(path);
          Settings.Save();
        }
      }
    }
    ui::ClearStatusText();
    if (!anime_item->GetFolder().empty()) {
      Execute(anime_item->GetFolder());
    }

  //////////////////////////////////////////////////////////////////////////////

  // PlayEpisode(value)
  //   Searches for an episode of an anime and plays it.
  //   lParam is an anime ID.
  } else if (action == L"PlayEpisode") {
    int number = ToInt(body);
    int anime_id = static_cast<int>(lParam);
    anime::PlayEpisode(anime_id, number);

  // PlayLast()
  //   Searches for the last watched episode of an anime and plays it.
  //   lParam is an anime ID.
  } else if (action == L"PlayLast") {
    int anime_id = static_cast<int>(lParam);
    anime::PlayLastEpisode(anime_id);

  // PlayNext([anime_id])
  //   Searches for the next episode of an anime and plays it.
  //   lParam is an anime ID.
  } else if (action == L"PlayNext") {
    int anime_id = body.empty() ? static_cast<int>(lParam) : ToInt(body);
    if (anime::IsValidId(anime_id)) {
      anime::PlayNextEpisode(anime_id);
    } else {
      anime::PlayNextEpisodeOfLastWatchedAnime();
    }

  // PlayRandom()
  //   Searches for a random episode of an anime and plays it.
  //   lParam is an anime ID.
  } else if (action == L"PlayRandom") {
    int anime_id = body.empty() ? static_cast<int>(lParam) : ToInt(body);
    anime::PlayRandomEpisode(anime_id);

  // PlayRandomAnime()
  //   Searches for a random episode of a random anime and plays it.
  } else if (action == L"PlayRandomAnime") {
    anime::PlayRandomAnime();

  //////////////////////////////////////////////////////////////////////////////

  // Season_Load(file)
  //   Loads season data.
  } else if (action == L"Season_Load") {
    if (SeasonDatabase.Load(body)) {
      SeasonDatabase.Review();
      ui::DlgSeason.RefreshList();
      ui::DlgSeason.RefreshStatus();
      ui::DlgSeason.RefreshToolbar();
      if (SeasonDatabase.IsRefreshRequired())
        if (ui::OnSeasonRefreshRequired())
          ui::DlgSeason.RefreshData();
    }

  // Season_GroupBy(group)
  //   Groups season data.
  } else if (action == L"Season_GroupBy") {
    ui::DlgSeason.group_by = ToInt(body);
    ui::DlgSeason.RefreshList();
    ui::DlgSeason.RefreshToolbar();

  // Season_SortBy(sort)
  //   Sorts season data.
  } else if (action == L"Season_SortBy") {
    ui::DlgSeason.sort_by = ToInt(body);
    ui::DlgSeason.RefreshList();
    ui::DlgSeason.RefreshToolbar();

  // Season_RefreshItemData()
  //   Refreshes an individual season item data.
  //   lParam is a pointer to a vector of anime IDs.
  } else if (action == L"Season_RefreshItemData") {
    const auto& anime_ids = *reinterpret_cast<std::vector<int>*>(lParam);
    for (const auto& anime_id : anime_ids) {
      ui::DlgSeason.RefreshData(anime_id);
    }

  // Season_ViewAs(mode)
  //   Changes view mode.
  } else if (action == L"Season_ViewAs") {
    ui::DlgSeason.SetViewMode(ToInt(body));
    ui::DlgSeason.RefreshList();
    ui::DlgSeason.RefreshToolbar();

  // Unknown
  } else {
    LOG(LevelWarning, L"Unknown action: " + action);
  }
}
fsInternetResult vmsMaliciousDownloadChecker::Check(LPCTSTR pszUrl)
{
	TCHAR szTmpPath [MY_MAX_PATH];
	TCHAR szTmpFile [MY_MAX_PATH];

	m_bNeedStop = false;

	GetTempPath (_countof (szTmpPath), szTmpPath);
	GetTempFileName (szTmpPath, _T("fdm"), 0, szTmpFile);

	
	CString strUrl;
	strUrl.Format (_T("http://fdm.freedownloadmanager.org/fromfdm/url.php?url=%s"), EncodeUrl (pszUrl));

	
	vmsSimpleFileDownloader dldr;
	m_dldr = &dldr;
	if (m_bNeedStop) {
		DeleteFile (szTmpFile);
		return IR_S_FALSE;
	}
	dldr.Download (strUrl, szTmpFile);
	while (dldr.IsRunning ())
		Sleep (50);
	m_dldr = NULL;
	if (dldr.GetLastError ().first != IR_SUCCESS) {
		DeleteFile (szTmpFile);
		return dldr.GetLastError ().first;
	}
	if (m_bNeedStop) {
		DeleteFile (szTmpFile);
		return IR_S_FALSE;
	}

	
	HANDLE hFile = CreateFile (szTmpFile, GENERIC_READ, 0, NULL, OPEN_EXISTING, 
		FILE_FLAG_DELETE_ON_CLOSE, NULL);
	ASSERT (hFile != INVALID_HANDLE_VALUE);
	if (hFile == INVALID_HANDLE_VALUE) {
		DeleteFile (szTmpFile);
		return IR_ERROR;
	}

	char szBuf [1000];
	DWORD dwSize = 0;
	ReadFile (hFile, szBuf, sizeof (szBuf), &dwSize, NULL);
	CloseHandle (hFile);

	if (dwSize == 0)
	{
		
		
		m_cOpinions = 0;
		m_cMalOpinions = 0;
		m_fRating = 0;
		m_strVirusCheckResult = _T("");
	}
	else
	{
		
		

		szBuf [dwSize] = 0;

		char szVCR [10000];
		sscanf (szBuf, "%d %f %d %s", &m_cOpinions, &m_fRating, &m_cMalOpinions, szVCR);

		std::wstring sRes;
		AnsiToUni(szBuf, sRes);

		m_strVirusCheckResult = sRes.c_str();
	}

	return IR_SUCCESS;
}