00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "FdmApp.h"
00008 #include "fsOpNetIntegrationMgr.h"
00009 #include "FolderBrowser.h"
00010
00011 #ifdef _DEBUG
00012 #undef THIS_FILE
00013 static char THIS_FILE[]=__FILE__;
00014 #define new DEBUG_NEW
00015 #endif
00016
00017 fsOpNetIntegrationMgr::fsOpNetIntegrationMgr()
00018 {
00019
00020 }
00021
00022 fsOpNetIntegrationMgr::~fsOpNetIntegrationMgr()
00023 {
00024
00025 }
00026
00027 void fsOpNetIntegrationMgr::Initialize()
00028 {
00029 CRegKey key;
00030
00031 CString strOpKey = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Opera.exe";
00032
00033 CString strNetKey1 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscp.exe";
00034 CString strNetKey2 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscp6.exe";
00035 CString strNetKey3 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Netscape.exe";
00036
00037 CString strFfKey = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\Firefox.exe";
00038
00039 CString strMozSKey1 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\SeaMonkey.exe";
00040 CString strMozSKey2 = "Software\\Microsoft\\Windows\\CurrentVersion\\App Paths\\mozilla.exe";
00041
00042 if (ERROR_SUCCESS == key.Open (HKEY_CURRENT_USER, "Software\\Opera Software", KEY_READ))
00043 {
00044 char szPath [MY_MAX_PATH] = "";
00045 DWORD dw = sizeof (szPath);
00046 if (ERROR_SUCCESS == key.QueryValue (szPath, "Plugin Path", &dw))
00047 {
00048 if (*szPath)
00049 {
00050 m_strOpPath = szPath;
00051 if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/')
00052 m_strOpPath += '\\';
00053 }
00054 }
00055 }
00056
00057 if (m_strOpPath == "" && ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strOpKey, KEY_READ))
00058 {
00059 char szPath [MY_MAX_PATH];
00060 DWORD dw = sizeof (szPath);
00061 key.QueryValue (szPath, "Path", &dw);
00062 m_strOpPath = szPath;
00063 if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/')
00064 m_strOpPath += '\\';
00065 if (GetFileAttributes (m_strOpPath + "program\\plugins") != DWORD (-1))
00066 m_strOpPath += "program\\plugins\\";
00067 else
00068 m_strOpPath += "Plugins\\";
00069 key.Close ();
00070 }
00071
00072 if (m_strOpPath == "")
00073 {
00074 m_strOpPath = _App.Monitor_OperaPDInstalledTo ();
00075 }
00076
00077 if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey1, KEY_READ) ||
00078 ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey2, KEY_READ) ||
00079 ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strNetKey3, KEY_READ))
00080 {
00081 char szPath [MY_MAX_PATH];
00082 DWORD dw = sizeof (szPath);
00083 key.QueryValue (szPath, "Path", &dw);
00084 m_strNetPath = szPath;
00085 if (m_strNetPath [m_strNetPath.GetLength () - 1] != '\\' || m_strNetPath [m_strNetPath.GetLength () - 1] != '/')
00086 m_strNetPath += '\\';
00087 m_strNetPath += "Plugins\\";
00088 key.Close ();
00089
00090 if (m_strNetPath == m_strOpPath)
00091 m_strNetPath = _App.Monitor_NetscapePDInstalledTo ();
00092 }
00093 else
00094 m_strNetPath = _App.Monitor_NetscapePDInstalledTo ();
00095
00096 if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strFfKey, KEY_READ))
00097 {
00098 char szPath [MY_MAX_PATH];
00099 DWORD dw = sizeof (szPath);
00100 key.QueryValue (szPath, "Path", &dw);
00101 m_strFfPath = szPath;
00102 if (m_strFfPath [m_strFfPath.GetLength () - 1] != '\\' || m_strFfPath [m_strFfPath.GetLength () - 1] != '/')
00103 m_strFfPath += '\\';
00104 m_strFfPath += "Plugins\\";
00105 key.Close ();
00106 }
00107 else
00108 m_strFfPath = _App.Monitor_FirefoxPDInstalledTo ();
00109
00110 if (ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strMozSKey1, KEY_READ) ||
00111 ERROR_SUCCESS == key.Open (HKEY_LOCAL_MACHINE, strMozSKey2, KEY_READ))
00112 {
00113
00114 char szPath [MY_MAX_PATH];
00115 DWORD dw = sizeof (szPath);
00116 key.QueryValue (szPath, "Path", &dw);
00117 m_strMozSPath = szPath;
00118 if (m_strMozSPath [m_strMozSPath.GetLength () - 1] != '\\' || m_strMozSPath [m_strMozSPath.GetLength () - 1] != '/')
00119 m_strMozSPath += '\\';
00120 m_strMozSPath += "Plugins\\";
00121 key.Close ();
00122 }
00123 else
00124 m_strMozSPath = _App.Monitor_MozillaSuitePDInstalledTo ();
00125 }
00126
00127 BOOL fsOpNetIntegrationMgr::IsOperaPluginInstalled(BOOL bQueryPluginDirIfUnknown)
00128 {
00129 if (m_strOpPath == "")
00130 {
00131 Initialize ();
00132 if (m_strOpPath.GetLength ())
00133 return IsOperaPluginInstalled (bQueryPluginDirIfUnknown);
00134
00135 if (bQueryPluginDirIfUnknown == FALSE)
00136 return FALSE;
00137
00138 if (MessageBox (NULL, LS (L_CANTFINDOPERADIR), PRG_NAME, MB_ICONEXCLAMATION|MB_YESNO) == IDNO)
00139 return FALSE;
00140
00141 CFolderBrowser *fb = CFolderBrowser::Create (LS (L_CHOOSEOUTFOLDER), NULL, NULL, NULL);
00142 if (fb == NULL)
00143 return FALSE;
00144
00145 m_strOpPath = fb->GetPath ();
00146
00147 if (m_strOpPath [m_strOpPath.GetLength () - 1] != '\\' || m_strOpPath [m_strOpPath.GetLength () - 1] != '/')
00148 m_strOpPath += '\\';
00149
00150 if (strnicmp (LPCSTR (m_strOpPath) + m_strOpPath.GetLength () - 8, "Plugins\\", 8))
00151 {
00152 if (GetFileAttributes (m_strOpPath + "program\\plugins") != DWORD (-1))
00153 m_strOpPath += "program\\plugins\\";
00154 else
00155 m_strOpPath += "Plugins\\";
00156 }
00157 }
00158
00159 CString str = m_strOpPath;
00160 str += "npfdm.dll";
00161 if (GetFileAttributes (str) == DWORD (-1))
00162 return FALSE;
00163 else
00164 return TRUE;
00165 }
00166
00167 BOOL fsOpNetIntegrationMgr::InstallOperaPlugin()
00168 {
00169 if (m_strOpPath == "")
00170 return FALSE;
00171
00172 CString str = m_strOpPath;
00173 str += "npfdm.dll";
00174 if (CopyFile ("npfdm.dll", str, FALSE))
00175 {
00176
00177 _App.Monitor_OperaPDInstalledTo (m_strOpPath);
00178 return TRUE;
00179 }
00180 else
00181 return FALSE;
00182 }
00183
00184 BOOL fsOpNetIntegrationMgr::DeinstallOperaPlugin()
00185 {
00186 if (m_strOpPath == "")
00187 return FALSE;
00188
00189 _App.Monitor_OperaPDInstalledTo ("");
00190
00191 CString str = m_strOpPath;
00192 str += "npfdm.dll";
00193
00194 m_strOpPath = "";
00195
00196 return DeleteFile (str);
00197 }
00198
00199 BOOL fsOpNetIntegrationMgr::IsNetscapePluginInstalled(BOOL bQueryPluginDirIfUnknown)
00200 {
00201 if (m_strNetPath == "")
00202 {
00203 Initialize ();
00204 if (m_strNetPath.GetLength ())
00205 return IsNetscapePluginInstalled (bQueryPluginDirIfUnknown);
00206
00207 if (bQueryPluginDirIfUnknown == FALSE)
00208 return FALSE;
00209
00210 if (MessageBox (NULL, LS (L_CANTFINDNETSCAPEDIR), PRG_NAME, MB_ICONEXCLAMATION|MB_YESNO) == IDNO)
00211 return FALSE;
00212
00213 CFolderBrowser *fb = CFolderBrowser::Create (LS (L_CHOOSEOUTFOLDER), NULL, NULL, NULL);
00214 if (fb == NULL)
00215 return FALSE;
00216
00217 m_strNetPath = fb->GetPath ();
00218 if (m_strNetPath [m_strNetPath.GetLength () - 1] != '\\' || m_strNetPath [m_strNetPath.GetLength () - 1] != '/')
00219 m_strNetPath += '\\';
00220 if (strnicmp (LPCSTR (m_strNetPath) + m_strNetPath.GetLength () - 8, "Plugins\\", 8))
00221 m_strNetPath += "Plugins\\";
00222 }
00223
00224 CString str = m_strNetPath;
00225 str += "npfdm.dll";
00226 if (GetFileAttributes (str) == DWORD (-1))
00227 return FALSE;
00228 else
00229 return TRUE;
00230 }
00231
00232 BOOL fsOpNetIntegrationMgr::InstallNetscapePlugin()
00233 {
00234 if (m_strNetPath == "")
00235 return FALSE;
00236
00237 CString str = m_strNetPath;
00238 str += "npfdm.dll";
00239 if (CopyFile ("npfdm.dll", str, FALSE))
00240 {
00241 _App.Monitor_NetscapePDInstalledTo (m_strNetPath);
00242 return TRUE;
00243 }
00244
00245 return FALSE;
00246 }
00247
00248 BOOL fsOpNetIntegrationMgr::DeinstallNetscapePlugin()
00249 {
00250 if (m_strNetPath == "")
00251 return FALSE;
00252
00253 _App.Monitor_NetscapePDInstalledTo ("");
00254
00255 CString str = m_strNetPath;
00256 str += "npfdm.dll";
00257
00258 m_strNetPath = "";
00259
00260 return DeleteFile (str);
00261 }
00262
00263 BOOL fsOpNetIntegrationMgr::IsFirefoxPluginInstalled(BOOL bQueryPluginDirIfUnknown)
00264 {
00265 if (m_strFfPath == "")
00266 {
00267 Initialize ();
00268 if (m_strFfPath.GetLength ())
00269 return IsFirefoxPluginInstalled (bQueryPluginDirIfUnknown);
00270
00271 if (bQueryPluginDirIfUnknown == FALSE)
00272 return FALSE;
00273
00274 if (MessageBox (NULL, LS (L_CANTFINDFIREFOXDIR), PRG_NAME, MB_ICONEXCLAMATION|MB_YESNO) == IDNO)
00275 return FALSE;
00276
00277 CFolderBrowser *fb = CFolderBrowser::Create (LS (L_CHOOSEOUTFOLDER), NULL, NULL, NULL);
00278 if (fb == NULL)
00279 return FALSE;
00280
00281 m_strFfPath = fb->GetPath ();
00282
00283 if (m_strFfPath [m_strFfPath.GetLength () - 1] != '\\' || m_strFfPath [m_strFfPath.GetLength () - 1] != '/')
00284 m_strFfPath += '\\';
00285
00286 if (strnicmp (LPCSTR (m_strFfPath) + m_strFfPath.GetLength () - 8, "Plugins\\", 8))
00287 m_strFfPath += "Plugins\\";
00288 }
00289
00290 CString str = m_strFfPath;
00291 str += "npfdm.dll";
00292 if (GetFileAttributes (str) == DWORD (-1))
00293 return FALSE;
00294 else
00295 return TRUE;
00296 }
00297
00298 BOOL fsOpNetIntegrationMgr::InstallFirefoxPlugin()
00299 {
00300 if (m_strFfPath == "")
00301 return FALSE;
00302
00303 CString str = m_strFfPath;
00304 str += "npfdm.dll";
00305 if (CopyFile ("npfdm.dll", str, FALSE))
00306 {
00307
00308 _App.Monitor_FirefoxPDInstalledTo (m_strFfPath);
00309 return TRUE;
00310 }
00311 else
00312 return FALSE;
00313 }
00314
00315 BOOL fsOpNetIntegrationMgr::DeinstallFirefoxPlugin()
00316 {
00317 if (m_strFfPath == "")
00318 return FALSE;
00319
00320 _App.Monitor_FirefoxPDInstalledTo ("");
00321
00322 CString str = m_strFfPath;
00323 str += "npfdm.dll";
00324
00325 m_strFfPath = "";
00326
00327 return DeleteFile (str);
00328 }
00329
00330 BOOL fsOpNetIntegrationMgr::IsMozillaSuitePluginInstalled(BOOL bQueryPluginDirIfUnknown)
00331 {
00332 if (m_strMozSPath == "")
00333 {
00334 Initialize ();
00335 if (m_strMozSPath.GetLength ())
00336 return IsMozillaSuitePluginInstalled (bQueryPluginDirIfUnknown);
00337 return FALSE;
00338 }
00339
00340 CString str = m_strMozSPath;
00341 str += "npfdm.dll";
00342 if (GetFileAttributes (str) == DWORD (-1))
00343 return FALSE;
00344 else
00345 return TRUE;
00346 }
00347
00348 BOOL fsOpNetIntegrationMgr::InstallMozillaSuitePlugin()
00349 {
00350 if (m_strMozSPath == "")
00351 return FALSE;
00352
00353 CString str = m_strMozSPath;
00354 str += "npfdm.dll";
00355 if (CopyFile ("npfdm.dll", str, FALSE))
00356 {
00357
00358 _App.Monitor_MozillaSuitePDInstalledTo (m_strMozSPath);
00359 return TRUE;
00360 }
00361 else
00362 return FALSE;
00363 }
00364
00365 BOOL fsOpNetIntegrationMgr::DeinstallMozillaSuitePlugin()
00366 {
00367 if (m_strMozSPath == "")
00368 return FALSE;
00369
00370 _App.Monitor_MozillaSuitePDInstalledTo ("");
00371
00372 CString str = m_strMozSPath;
00373 str += "npfdm.dll";
00374
00375 m_strMozSPath = "";
00376
00377 return DeleteFile (str);
00378 }