00001
00002
00003
00004
00005
00006 #include "stdafx.h"
00007 #include "vmsFirefoxExtensionInstaller.h"
00008 #include "vmsFirefoxUtil.h"
00009 #include "vmsFile.h"
00010 using namespace vmsFDM;
00011
00012 vmsFirefoxExtensionInstaller::vmsFirefoxExtensionInstaller()
00013 {
00014
00015 }
00016
00017 vmsFirefoxExtensionInstaller::~vmsFirefoxExtensionInstaller()
00018 {
00019
00020 }
00021
00022 bool vmsFirefoxExtensionInstaller::Do(LPCSTR pszCID, LPCSTR pszExtPath, bool bInstall)
00023 {
00024 LOG ("vmsFEI::Do: in" << nl);
00025
00026 FU_STRINGLIST v; int nDefProf;
00027 vmsFirefoxUtil::GetProfilesPathes (v, nDefProf);
00028
00029 LOG ("vmsFEI::Do: " << v.size () << " profiles found" << nl);
00030
00031 if (v.size () == 0)
00032 return false;
00033
00034 for (int i = 0; i < v.size (); i++)
00035 {
00036 char sz [MY_MAX_PATH];
00037 lstrcpy (sz, v [i]);
00038 lstrcat (sz, "\\extensions\\");
00039 lstrcat (sz, pszCID);
00040
00041 if (bInstall)
00042 {
00043 fsBuildPathToFile (sz);
00044
00045 try{
00046
00047 vmsFile file;
00048 LOG ("vmsFEI::Do: creating file: " << sz << nl);
00049 file.Create (sz, GENERIC_WRITE, 0, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL);
00050 LOG ("vmsFEI::Do: writing to it" << nl);
00051 file.Write (pszExtPath, lstrlen (pszExtPath));
00052 LOG ("vmsFEI::Do: closing it" << nl);
00053 file.Close ();
00054 LOG ("vmsFEI::Do: done" << nl);
00055
00056 }catch (...) {
00057 LOG ("vmsFEI::Do: failed write ext ptr file" << nl);
00058 return false;
00059 }
00060 }
00061 else
00062 {
00063 DeleteFile (sz);
00064 }
00065 }
00066
00067 LOG ("vmsFEI::Do: ok" << nl);
00068
00069 return true;
00070 }
00071
00072 bool vmsFirefoxExtensionInstaller::IsInstalled(LPCSTR pszCID, bool bInDefaultProfileOnly)
00073 {
00074 LOG ("vmsFEI::IsInst: in" << nl);
00075
00076 FU_STRINGLIST v; int nDefaultProfile;
00077 vmsFirefoxUtil::GetProfilesPathes (v, nDefaultProfile);
00078
00079 LOG ("vmsFEI::IsInst: " << v.size () << " profiles found" << nl);
00080
00081 if (v.size () == 0)
00082 return false;
00083
00084 if (nDefaultProfile == -1 || nDefaultProfile >= v.size ())
00085 bInDefaultProfileOnly = false;
00086
00087 for (int i = 0; i < v.size (); i++)
00088 {
00089 if (bInDefaultProfileOnly && i != nDefaultProfile)
00090 continue;
00091
00092 char sz [MY_MAX_PATH];
00093 lstrcpy (sz, v [i]);
00094 lstrcat (sz, "\\extensions\\");
00095 lstrcat (sz, pszCID);
00096
00097 LOG ("vmsFEI::IsInst: checking file presense: " << sz << nl);
00098
00099 if (GetFileAttributes (sz) != DWORD (-1))
00100 {
00101 LOG ("vmsFEI::IsInst: ok (yes)" << nl);
00102 return true;
00103 }
00104 }
00105
00106 LOG ("vmsFEI::IsInst: ok (no)" << nl);
00107 return false;
00108 }