00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "fsUrlsToDownloadRegKeyMgr.h"
00009 #include "DownloadsWnd.h"
00010
00011 extern CDownloadsWnd* _pwndDownloads;
00012
00013 #ifdef _DEBUG
00014 #undef THIS_FILE
00015 static char THIS_FILE[]=__FILE__;
00016 #define new DEBUG_NEW
00017 #endif
00018
00019 fsUrlsToDownloadRegKeyMgr::fsUrlsToDownloadRegKeyMgr()
00020 {
00021
00022 }
00023
00024 fsUrlsToDownloadRegKeyMgr::~fsUrlsToDownloadRegKeyMgr()
00025 {
00026
00027 }
00028
00029 void fsUrlsToDownloadRegKeyMgr::CheckKey()
00030 {
00031 CRegKey key;
00032
00033 LOG ("cheking URLsToDownload reg key...");
00034
00035 if (ERROR_SUCCESS != key.Open (HKEY_CURRENT_USER,
00036 "Software\\OpenDownloadManager.ORG\\Open Download Manager\\URLsToDownload"))
00037 {
00038 LOG ("failed to open key" << nl);
00039 return;
00040 }
00041
00042 LOG (nl);
00043
00044 fs::list <fsString> vKeys;
00045 BOOL bZL = _DldsMgr.GetCount () == 0;
00046
00047 for (int i = 0; TRUE; i++)
00048 {
00049 char szKeyName [10000];
00050 DWORD dwLen = sizeof (szKeyName);
00051
00052 if (ERROR_SUCCESS != RegEnumKey (key, i, szKeyName, dwLen))
00053 break;
00054
00055 CRegKey key2;
00056 if (ERROR_SUCCESS == key2.Open (key, szKeyName))
00057 {
00058 char szUrl [10000];
00059 DWORD dw = sizeof (szUrl);
00060 DWORD bSilent = FALSE;
00061 char szComment [10000] = "";
00062 DWORD dwCS = sizeof (szComment);
00063 DWORD bAutoStart = TRUE;
00064 DWORD bZLR = FALSE;
00065 DWORD dwForceAutoLaunch = DWCD_NOFORCEAUTOLAUNCH;
00066 DWORD bSaveToDesktop = FALSE;
00067
00068 key2.QueryValue (bSilent, "Silent");
00069 key2.QueryValue (szComment, "Comment", &dwCS);
00070 key2.QueryValue (bAutoStart, "AutoStart");
00071 key2.QueryValue (bZLR, "zlr");
00072 key2.QueryValue (dwForceAutoLaunch, "ForceAutoLaunch");
00073 key2.QueryValue (bSaveToDesktop, "SaveToDesktop");
00074
00075 if (bZLR == FALSE || bZL)
00076 if (ERROR_SUCCESS == key2.QueryValue (szUrl, "URL", &dw))
00077 {
00078 char szReferer [10000];
00079 dw = sizeof (szReferer);
00080 *szReferer = 0;
00081
00082 key2.QueryValue (szReferer, "Referer", &dw);
00083
00084 LOG ("another url found" << nl);
00085
00086 fsURL url;
00087 if (url.Crack (szUrl) == IR_SUCCESS)
00088 {
00089 vmsDWCD_AdditionalParameters params;
00090 params.dwMask = DWCDAP_FLAGS;
00091 params.dwFlags = bSaveToDesktop ? DWDCDAP_F_SAVETODESKTOP : 0;
00092 _pwndDownloads->CreateDownload (szUrl, FALSE, szComment, *szReferer ? szReferer : NULL,
00093 bSilent, dwForceAutoLaunch, (LPBOOL)&bAutoStart, ¶ms);
00094 }
00095 else
00096 LOG ("bad url" << nl);
00097
00098 LOG ("url processed" << nl);
00099 }
00100 }
00101
00102 vKeys.add (szKeyName);
00103 }
00104
00105 LOG ("deleting all URLsToDownload reg key entries...");
00106
00107 for (i = 0; i < vKeys.size (); i++)
00108 key.RecurseDeleteKey (vKeys [i]);
00109
00110 LOG ("done." << nl);
00111 }