Enable Firefox support on Windows, and checkpoint Windows Project files.

This commit is contained in:
Jim Norman
2006-04-13 16:03:49 +00:00
parent 7684bc7aee
commit 7a72dfc4a1
17 changed files with 925 additions and 479 deletions

View File

@@ -29,197 +29,204 @@ using System.Collections;
namespace Novell.CASA.DataEngines.FF
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class Host
{
public IntPtr hostName;
public IntPtr hostElement;
public IntPtr next;
/*public Host()
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class Host
{
public IntPtr hostName;
public IntPtr hostElement;
public IntPtr next;
/*public Host()
//NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
//WE MARSHAL PTR TO STRUCTURE
{
hostName = Marshal.AllocHGlobal(128);
}
~Host()
{
hostName = Marshal.AllocHGlobal(128);
}
~Host()
{
try
{
Marshal.FreeHGlobal(hostName);
Marshal.FreeHGlobal(hostName);
}
catch (Exception e)
{
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for Host:");
}
}*/
};
}*/
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class HostElement
{
public IntPtr name;
public IntPtr value;
public int isPassword;
public IntPtr next;
/*public HostElement()
{
name = Marshal.AllocHGlobal(128);
value = Marshal.AllocHGlobal(128);
}
~HostElement()
{
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class HostElement
{
public IntPtr name;
public IntPtr value;
public int isPassword;
public IntPtr next;
/*public HostElement()
{
name = Marshal.AllocHGlobal(128);
value = Marshal.AllocHGlobal(128);
}
~HostElement()
{
try
{
Marshal.FreeHGlobal(name);
Marshal.FreeHGlobal(value);
Marshal.FreeHGlobal(name);
Marshal.FreeHGlobal(value);
}
catch (Exception e)
{
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for HostElement:");
Console.WriteLine("FireFox:Marshal FreeHGlobal Exception for HostElement:");
}
}*/
};
}*/
};
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class KeyringInfo
{
public int lockOnIdle;
public uint lockTimeout;
public uint mTime;
public uint cTime;
public int isLocked;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class NativeItemInfo
{
public int itemType;
public IntPtr displayName;
public IntPtr secret;
public int mTime;
public int cTime;
public NativeItemInfo()
{
displayName = Marshal.AllocHGlobal(128);
secret = Marshal.AllocHGlobal(128);
}
~NativeItemInfo()
{
Marshal.FreeHGlobal(displayName);
Marshal.FreeHGlobal(secret);
}
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class KeyringInfo
{
public int lockOnIdle;
public uint lockTimeout;
public uint mTime;
public uint cTime;
public int isLocked;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class NativeItemInfo
{
public int itemType;
public IntPtr displayName;
public IntPtr secret;
public int mTime;
public int cTime;
public NativeItemInfo()
{
displayName = Marshal.AllocHGlobal(128);
secret = Marshal.AllocHGlobal(128);
}
~NativeItemInfo()
{
Marshal.FreeHGlobal(displayName);
Marshal.FreeHGlobal(secret);
}
}
public class ItemInfo
{
public string itemType;
public string displayName;
public string secret;
public int mTime;
public int cTime;
}
public class ItemInfo
{
public string itemType;
public string displayName;
public string secret;
public int mTime;
public int cTime;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class NativeAttribute
{
public uint type;
public IntPtr key;
public IntPtr value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class NativeAttribute
{
public uint type;
public IntPtr key;
public IntPtr value;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class Attribute
{
public uint type;
public string key;
public string value;
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public class Attribute
{
public uint type;
public string key;
public string value;
}
}
public class FireFox
{
private static int MAX_PROFILES = 5; //FIXME:Maximum Profiles for Firefox - To be removed when done dynamically via a native api
private static int LOAD_PROFILE_ALWAYSFROM_FILE = 1;
public class FireFox
{
private static int MAX_PROFILES = 5; //FIXME:Maximum Profiles for Firefox - To be removed when done dynamically via a native api
private static int LOAD_PROFILE_ALWAYSFROM_FILE = 1;
#if WIN32
private const string FF_LIB = "ad_ff.dll";
#else
private const string FF_LIB = "libad_ff.so.1.1.1";
#endif
//Initialization functions
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_GetProfileList(out IntPtr[] profileList, out IntPtr[] profileFlag);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_FirefoxProfileInit(string profileName);
//Initialization functions
[DllImport(FF_LIB)]
public static extern int FPM_GetProfileList(out IntPtr[] profileList, out IntPtr[] profileFlag);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_IsStoreAvailable();
[DllImport(FF_LIB)]
public static extern int FPM_FirefoxProfileInit(string profileName);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_FirefoxProfileExit(string profileName);
[DllImport(FF_LIB)]
public static extern int FPM_IsStoreAvailable();
//Master Password functions
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_IsMasterPasswordSet(string profileName);
[DllImport(FF_LIB)]
public static extern int FPM_FirefoxProfileExit(string profileName);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_CheckMasterPassword(string profileName, string masterPassword);
//Master Password functions
[DllImport(FF_LIB)]
public static extern int FPM_IsMasterPasswordSet(string profileName);
//Signon functions
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh);
[DllImport(FF_LIB)]
public static extern int FPM_CheckMasterPassword(string profileName, string masterPassword);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
//Signon functions
[DllImport(FF_LIB)]
public static extern int FPM_GetSignonData(string profileName,out IntPtr host,int doRefresh);
[DllImport("libad_ff.so.1.1.1")]
public static extern int FPM_RemoveHost(string profileName, string hostName, int doUpdate);
[DllImport(FF_LIB)]
public static extern int FPM_ModifyHost(string profileName, Host host, int doUpdate);
//TBD
//int FPM_WriteSignonData(char *profileName)
//int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
[DllImport(FF_LIB)]
public static extern int FPM_RemoveHost(string profileName, string hostName, int doUpdate);
//TBD
//int FPM_WriteSignonData(char *profileName)
//int FPM_AddHost(char *profileName, struct Host *host, int doUpdate)
public static int IsStoreAvailable()
{
return FPM_IsStoreAvailable();
}
public static int IsStoreAvailable()
{
return FPM_IsStoreAvailable();
}
public static int Remove_Host(string ProfileName, string hostName)
{
return (FPM_RemoveHost(ProfileName, hostName, 1));
}
public static int Remove_Host(string ProfileName, string hostName)
{
return (FPM_RemoveHost(ProfileName, hostName, 1));
}
public static int Modify_Host(string profileName, Host mhost, int doUpdate)
{
//Console.WriteLine("FireFox.cs : ProfileName : " + profileName);
//Console.WriteLine("FireFox.cs : HostName : " + (String)Marshal.PtrToStringAnsi(mhost.hostName));
public static int Modify_Host(string profileName, Host mhost, int doUpdate)
{
//Console.WriteLine("FireFox.cs : ProfileName : " + profileName);
//Console.WriteLine("FireFox.cs : HostName : " + (String)Marshal.PtrToStringAnsi(mhost.hostName));
return FPM_ModifyHost(profileName, mhost,1);
}
return FPM_ModifyHost(profileName, mhost,1);
}
//--------------------------------------------------------------
//GetDefaultProfileName
//@param None
//@return Default ProfileName on success
// else null if not retrivable
//--------------------------------------------------------------
public static String GetDefaultProfileName()
{
//--------------------------------------------------------------
//GetDefaultProfileName
//@param None
//@return Default ProfileName on success
// else null if not retrivable
//--------------------------------------------------------------
public static String GetDefaultProfileName()
{
IntPtr[] profileListIntPtr=new IntPtr[MAX_PROFILES];;
IntPtr[] profileFlagsIntPtr=new IntPtr[MAX_PROFILES];;
String[] profileList=null;
int[] profileFlags=null;
String profileName=null;
int profileFlag=0;
int profCount=0;
String defaultProfileName=null;
IntPtr[] profileListIntPtr=new IntPtr[MAX_PROFILES];;
IntPtr[] profileFlagsIntPtr=new IntPtr[MAX_PROFILES];;
String[] profileList=null;
int[] profileFlags=null;
String profileName=null;
int profileFlag=0;
int profCount=0;
String defaultProfileName=null;
//Console.WriteLine("FireFox:Invoking FPM_GetProfileList:");
profCount=FPM_GetProfileList(out profileListIntPtr,out profileFlagsIntPtr);
//Console.WriteLine("FireFox:No of Profiles found= "+profCount);
//Console.WriteLine("FireFox:Invoking FPM_GetProfileList:");
profCount=FPM_GetProfileList(out profileListIntPtr,out profileFlagsIntPtr);
//Console.WriteLine("FireFox:No of Profiles found= "+profCount);
//try
///{
//try
///{
for(int i=0; i< profCount; i++)
{
//Console.WriteLine("Firefox.cs : Inside The for Loop");
@@ -232,167 +239,163 @@ public class HostElement
}
return defaultProfileName;
}
return defaultProfileName;
}
//--------------------------------------------------------------
//GetAllProfileNames
//@param None
//@return ProfileNames (String[]) - List of all Profile Names
// else null
//--------------------------------------------------------------
public static String[] GetAllProfileNames()
{
//TBD:To be implemented if\when required
return null;
}
//--------------------------------------------------------------
//GetAllProfileNames
//@param None
//@return ProfileNames (String[]) - List of all Profile Names
// else null
//--------------------------------------------------------------
public static String[] GetAllProfileNames()
{
//TBD:To be implemented if\when required
return null;
}
//--------------------------------------------------------------
//GetProfileData
//GetProfileData for the specified profile
//@param
// profileName (string)
//
//@return hostList (Host) on success
// else null
//--------------------------------------------------------------
public static Host GetProfileData(string profileName)
{
Host hostList; // = new Host(); - NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
// WE MARSHAL PTR TO STRUCTURE
int methodStatusCode=-1;
String defaultProfileName = null;
int initProfileStatus = -1;
//--------------------------------------------------------------
//GetProfileData
//GetProfileData for the specified profile
//@param
// profileName (string)
//
//@return hostList (Host) on success
// else null
//--------------------------------------------------------------
public static Host GetProfileData(string profileName)
{
Host hostList; // = new Host(); - NOT NEEDED SINCE WE GET THIS FILLED FROM NATIVE WHEN
// WE MARSHAL PTR TO STRUCTURE
int methodStatusCode=-1;
String defaultProfileName = null;
int initProfileStatus = -1;
//if(methodStatusCode==1)
{//If Init of the profile was sucessfull, get the sigon data to complete the aggregation
IntPtr hostListIntPtr = new IntPtr();
try
{
//Console.WriteLine("FireFox:Getting Data for profile "+profileName);
methodStatusCode=-1;
methodStatusCode = FPM_GetSignonData(profileName,out hostListIntPtr,LOAD_PROFILE_ALWAYSFROM_FILE);
if( 1 != methodStatusCode )
{
//Console.WriteLine("FireFox:Getting Data for profile Failed with error "+methodStatusCode);
hostList=null;
return hostList;
}
{//If Init of the profile was sucessfull, get the sigon data to complete the aggregation
IntPtr hostListIntPtr = new IntPtr();
try
{
//Console.WriteLine("FireFox:Getting Data for profile "+profileName);
methodStatusCode=-1;
methodStatusCode = FPM_GetSignonData(profileName,out hostListIntPtr,LOAD_PROFILE_ALWAYSFROM_FILE);
if( 1 != methodStatusCode )
{
//Console.WriteLine("FireFox:Getting Data for profile Failed with error "+methodStatusCode);
hostList=null;
return hostList;
}
hostList = null;
hostList = (Host)Marshal.PtrToStructure(hostListIntPtr, typeof(Host));
//This can be Null only when nothing is aggregated.
if (((String)Marshal.PtrToStringAnsi(hostList.hostName)) == null )
{
//TBD: Log that there are no secrets to aggregate
//Console.WriteLine("FireFox:no secrets to aggregate");
hostList = null;
hostList = (Host)Marshal.PtrToStructure(hostListIntPtr, typeof(Host));
//This can be Null only when nothing is aggregated.
if (((String)Marshal.PtrToStringAnsi(hostList.hostName)) == null )
{
//TBD: Log that there are no secrets to aggregate
//Console.WriteLine("FireFox:no secrets to aggregate");
hostList = null;
}
}
catch(Exception e)
{
//Console.WriteLine("FireFox:Exception during invokation of FPM_GetSignonData");
//Console.WriteLine(e.ToString());
hostList = null;
}
//Uninitialize the profile
//Console.WriteLine("FireFox:UnInitializing the Profile "+profileName);
//UninitProfile(profileName);
}
return hostList;
}
catch(Exception e)
{
//Console.WriteLine("FireFox:Exception during invokation of FPM_GetSignonData");
//Console.WriteLine(e.ToString());
hostList = null;
}
//--------------------------------------------------------------
//InitFFProfile
//@param profileName name of the profile
//@return 1 on success
// <=0 on error
//--------------------------------------------------------------
public static int InitProfile(string profileName)
{
return FPM_FirefoxProfileInit(profileName);
}
//Uninitialize the profile
//Console.WriteLine("FireFox:UnInitializing the Profile "+profileName);
//UninitProfile(profileName);
}
return hostList;
}
//=================================================================
//--------------------------------------------------------------
//UninitProfile
//UninitProfile for the specified profile
//@param
// profileName (string)
//
//@return 1 on success
// <=0 on error
//--------------------------------------------------------------
public static int UninitProfile(string profileName)
{
int methodStatusCode=-1;
//Console.WriteLine("FireFox:UninitProfile for "+profileName);
methodStatusCode=-1;
methodStatusCode = FPM_FirefoxProfileExit(profileName);
/*if( 1 != methodStatusCode )
//--------------------------------------------------------------
//InitFFProfile
//@param profileName name of the profile
//@return 1 on success
// <=0 on error
//--------------------------------------------------------------
public static int InitProfile(string profileName)
{
Console.WriteLine("FireFox:UninitProfile Failed with error "+methodStatusCode);
return FPM_FirefoxProfileInit(profileName);
}
//=================================================================
//--------------------------------------------------------------
//UninitProfile
//UninitProfile for the specified profile
//@param
// profileName (string)
//
//@return 1 on success
// <=0 on error
//--------------------------------------------------------------
public static int UninitProfile(string profileName)
{
int methodStatusCode=-1;
//Console.WriteLine("FireFox:UninitProfile for "+profileName);
methodStatusCode=-1;
methodStatusCode = FPM_FirefoxProfileExit(profileName);
/*if( 1 != methodStatusCode )
{
Console.WriteLine("FireFox:UninitProfile Failed with error "+methodStatusCode);
} */
return methodStatusCode;
}
return methodStatusCode;
}
//--------------------------------------------------------------
//isMasterPasswordSetFor
//Is MasterPassword Set For specified profile
//@param
// profileName (string)
//
//@param profileName name of the profile
// @return 1 if master password is set
// 0 if master password not set
//--------------------------------------------------------------
public static int isMasterPasswordSetFor(string profileName)
{
int methodStatusCode=0;
//--------------------------------------------------------------
//isMasterPasswordSetFor
//Is MasterPassword Set For specified profile
//@param
// profileName (string)
//
//@param profileName name of the profile
// @return 1 if master password is set
// 0 if master password not set
//--------------------------------------------------------------
public static int isMasterPasswordSetFor(string profileName)
{
int methodStatusCode=0;
//Console.WriteLine("FireFox:isMasterPasswordSetFor "+profileName);
methodStatusCode = FPM_IsMasterPasswordSet(profileName);
//Console.WriteLine("FireFox:isMasterPasswordSetFor "+profileName);
methodStatusCode = FPM_IsMasterPasswordSet(profileName);
return methodStatusCode;
}
return methodStatusCode;
}
//--------------------------------------------------------------
//checkMasterPassword
//Check if the specified master password is correct or not.
//If it is correct then password is stored to the internal store for later use.
//If it is wrong then nothing is stored and 0 will be returned.
//
//@param
// profileName (string)
// masterPassword (string)
//
// @return 1 if the specified master password is correct
// 0 if the master password is wrong.
//--------------------------------------------------------------
public static int checkMasterPassword(string profileName,string masterPassword)
{
int methodStatusCode=0;
//--------------------------------------------------------------
//checkMasterPassword
//Check if the specified master password is correct or not.
//If it is correct then password is stored to the internal store for later use.
//If it is wrong then nothing is stored and 0 will be returned.
//
//@param
// profileName (string)
// masterPassword (string)
//
// @return 1 if the specified master password is correct
// 0 if the master password is wrong.
//--------------------------------------------------------------
public static int checkMasterPassword(string profileName,string masterPassword)
{
int methodStatusCode=0;
//Console.WriteLine("FireFox:checking MasterPassword for "+profileName);
methodStatusCode = FPM_CheckMasterPassword(profileName,masterPassword);
//Console.WriteLine("FireFox:checking MasterPassword for "+profileName);
methodStatusCode = FPM_CheckMasterPassword(profileName,masterPassword);
return methodStatusCode;
}
//=================Local Methods====================================
return methodStatusCode;
}
//=================Local Methods====================================
}
}

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="ad_firefox_native"
ProjectGUID="{BB304ECF-FCBA-4693-9D47-86749815DDC8}"
RootNamespace="ad_firefox_native"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;FIREFOX_EXPORTS"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="D:/casaClean2/c_gui/Debug/ad_ff.dll"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/firefox.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/firefox.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;FIREFOX_EXPORTS"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/ad_ff.dll"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
ImportLibrary="$(OutDir)/firefox.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\native\Common.cpp">
</File>
<File
RelativePath=".\native\CryptManager.cpp">
</File>
<File
RelativePath=".\native\DataManager.cpp">
</File>
<File
RelativePath=".\native\FirefoxPasswordManager.cpp">
</File>
<File
RelativePath=".\native\ProfileManager.cpp">
</File>
<File
RelativePath=".\native\SignonManager.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\native\Common.h">
</File>
<File
RelativePath=".\native\CryptManager.h">
</File>
<File
RelativePath=".\native\DataManager.h">
</File>
<File
RelativePath=".\native\FirefoxPasswordManager.h">
</File>
<File
RelativePath=".\native\ProfileManager.h">
</File>
<File
RelativePath=".\native\SignonManager.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>