Compare commits
14 Commits
MAPI_NEW_D
...
RDF_XPCOM_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0b2424f7ca | ||
|
|
75bfddcd5c | ||
|
|
d67638c1e0 | ||
|
|
021dfd7c81 | ||
|
|
272deb6ee9 | ||
|
|
f81f4440bd | ||
|
|
914f82571b | ||
|
|
0f1dfe3d0d | ||
|
|
05693f5648 | ||
|
|
26c6838a88 | ||
|
|
90406a1af2 | ||
|
|
41eefd7f6c | ||
|
|
ab25b9b291 | ||
|
|
a151d7380d |
@@ -1,70 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
/**
|
||||
* This interface provides support for registering Mozilla as the default
|
||||
* Mail Client. This interface can also be used to get/set the user preference
|
||||
* for the default Mail Client.
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(c5be14ba-4e0a-4eec-a1b8-04363761d63c)]
|
||||
interface nsIMapiRegistry: nsISupports {
|
||||
|
||||
/** This is set to TRUE if Mozilla is the default Application
|
||||
*/
|
||||
attribute boolean isDefaultMailClient;
|
||||
|
||||
/** This is set TRUE only once per session.
|
||||
*/
|
||||
readonly attribute boolean showDialog;
|
||||
|
||||
/** This will bring the dialog asking the user if he/she wants to set
|
||||
* Mozilla as default Mail Client.
|
||||
* Call this only if Mozilla is not the default Mail client
|
||||
*/
|
||||
void showMailIntegrationDialog(in nsIDOMWindow parentWindow);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IMAPIREGISTRY_CONTRACTID "@mozilla.org/mapiregistry;1"
|
||||
#define NS_IMAPIREGISTRY_CLASSNAME "Mozilla MAPI Registry"
|
||||
%}
|
||||
@@ -1,27 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Srilatha Moturi <srilatha@netscape.com>
|
||||
# Krishna Mohan Khandrika <kkhandrika@netscape.com>
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=mapihook resources mapiDll
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,54 +0,0 @@
|
||||
; ***** BEGIN LICENSE BLOCK *****
|
||||
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;
|
||||
; The contents of this file are subject to the Mozilla Public License Version
|
||||
; 1.1 (the "License"); you may not use this file except in compliance with
|
||||
; the License. You may obtain a copy of the License at
|
||||
; http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
; for the specific language governing rights and limitations under the
|
||||
; License.
|
||||
;
|
||||
; The Original Code is Mozilla.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; Netscape Communications Corp.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2001
|
||||
; the Initial Developer. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the terms of
|
||||
; either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
; in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
; of those above. If you wish to allow use of your version of this file only
|
||||
; under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
; use your version of this file under the terms of the MPL, indicate your
|
||||
; decision by deleting the provisions above and replace them with the notice
|
||||
; and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
; the provisions above, a recipient may use your version of this file under
|
||||
; the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;
|
||||
; ***** END LICENSE BLOCK *****
|
||||
|
||||
LIBRARY mozMapi32.dll
|
||||
DESCRIPTION 'Mozilla Simple MAPI Support'
|
||||
|
||||
EXPORTS
|
||||
MAPILogon
|
||||
MAPILogoff
|
||||
MAPISendMail
|
||||
MAPISendDocuments
|
||||
MAPIFindNext
|
||||
MAPIReadMail
|
||||
MAPISaveMail
|
||||
MAPIDeleteMail
|
||||
MAPIAddress
|
||||
MAPIDetails
|
||||
MAPIResolveName
|
||||
MAPIFreeBuffer
|
||||
GetMapiDllVersion
|
||||
|
||||
@@ -1,346 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
* Contributor(s): Rajiv Dayal (rdayal@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <mapidefs.h>
|
||||
#include <mapi.h>
|
||||
#include "msgMapi.h"
|
||||
#include "msgMapiMain.h"
|
||||
|
||||
#define MAX_RECIPS 100
|
||||
#define MAX_FILES 100
|
||||
|
||||
const CLSID CLSID_CMapiImp = {0x29f458be, 0x8866, 0x11d5,
|
||||
{0xa3, 0xdd, 0x0, 0xb0, 0xd0, 0xf3, 0xba, 0xa7}};
|
||||
const IID IID_nsIMapi = {0x6EDCD38E,0x8861,0x11d5,
|
||||
{0xA3,0xDD,0x00,0xB0,0xD0,0xF3,0xBA,0xA7}};
|
||||
|
||||
DWORD tId = 0;
|
||||
|
||||
BOOL WINAPI DllMain(HINSTANCE aInstance, DWORD aReason, LPVOID aReserved)
|
||||
{
|
||||
switch (aReason)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH : tId = TlsAlloc();
|
||||
if (tId == 0xFFFFFFFF)
|
||||
return FALSE;
|
||||
break;
|
||||
|
||||
case DLL_PROCESS_DETACH : TlsFree(tId);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL InitMozillaReference(nsIMapi **aRetValue)
|
||||
{
|
||||
// Check wehther this thread has a valid Interface
|
||||
// by looking into thread-specific-data variable
|
||||
|
||||
*aRetValue = (nsIMapi *)TlsGetValue(tId);
|
||||
|
||||
// Check whether the pointer actually resolves to
|
||||
// a valid method call; otherwise mozilla is not running
|
||||
|
||||
if ((*aRetValue) && (*aRetValue)->IsValid() == S_OK)
|
||||
return TRUE;
|
||||
|
||||
HRESULT hRes = ::CoInitialize(nsnull) ;
|
||||
|
||||
hRes = ::CoCreateInstance(CLSID_CMapiImp, NULL, CLSCTX_LOCAL_SERVER,
|
||||
IID_nsIMapi, (LPVOID *)aRetValue);
|
||||
|
||||
if (hRes == S_OK && (*aRetValue)->Initialize() == S_OK)
|
||||
if (TlsSetValue(tId, (LPVOID)(*aRetValue)))
|
||||
return TRUE;
|
||||
|
||||
// Either CoCreate or TlsSetValue failed; so return FALSE
|
||||
|
||||
if ((*aRetValue))
|
||||
(*aRetValue)->Release();
|
||||
|
||||
::CoUninitialize();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
// The MAPILogon function begins a Simple MAPI session, loading the default message ////
|
||||
// store and address book providers ////
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ULONG FAR PASCAL MAPILogon(ULONG aUIParam, LPTSTR aProfileName,
|
||||
LPTSTR aPassword, FLAGS aFlags,
|
||||
ULONG aReserved, LPLHANDLE aSession)
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
ULONG nSessionId = 0;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
if (!(aFlags & MAPI_UNICODE))
|
||||
{
|
||||
// Need to convert the parameters to Unicode.
|
||||
|
||||
char *pUserName = (char *) aProfileName;
|
||||
char *pPassWord = (char *) aPassword;
|
||||
|
||||
TCHAR ProfileName[MAX_NAME_LEN] = {0};
|
||||
TCHAR PassWord[MAX_PW_LEN] = {0};
|
||||
|
||||
if (pUserName != NULL)
|
||||
{
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, pUserName, -1, ProfileName,
|
||||
MAX_NAME_LEN))
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
if (pPassWord != NULL)
|
||||
{
|
||||
if (!MultiByteToWideChar(CP_ACP, 0, pPassWord, -1, PassWord,
|
||||
MAX_NAME_LEN))
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
hr = pNsMapi->Login(aUIParam, ProfileName, PassWord, aFlags,
|
||||
&nSessionId);
|
||||
}
|
||||
else
|
||||
hr = pNsMapi->Login(aUIParam, aProfileName, aPassword,
|
||||
aFlags, &nSessionId);
|
||||
if (hr == S_OK)
|
||||
(*aSession) = (LHANDLE) nSessionId;
|
||||
else
|
||||
return nSessionId;
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPILogoff (LHANDLE aSession, ULONG aUIParam,
|
||||
FLAGS aFlags, ULONG aReserved)
|
||||
{
|
||||
nsIMapi *pNsMapi = (nsIMapi *)TlsGetValue(tId);
|
||||
if (pNsMapi != NULL)
|
||||
{
|
||||
if (pNsMapi->Logoff((ULONG) aSession) == S_OK)
|
||||
pNsMapi->Release();
|
||||
pNsMapi = NULL;
|
||||
}
|
||||
|
||||
TlsSetValue(tId, NULL);
|
||||
|
||||
::CoUninitialize();
|
||||
|
||||
return SUCCESS_SUCCESS;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPISendMail (LHANDLE lhSession, ULONG ulUIParam, lpnsMapiMessage lpMessage,
|
||||
FLAGS flFlags, ULONG ulReserved )
|
||||
{
|
||||
HRESULT hr = 0;
|
||||
BOOL bTempSession = FALSE ;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
if (lpMessage->nRecipCount > MAX_RECIPS)
|
||||
return MAPI_E_TOO_MANY_RECIPIENTS ;
|
||||
|
||||
if (lpMessage->nFileCount > MAX_FILES)
|
||||
return MAPI_E_TOO_MANY_FILES ;
|
||||
|
||||
if ( (!(flFlags & MAPI_DIALOG)) && (lpMessage->lpRecips == NULL) )
|
||||
return MAPI_E_UNKNOWN_RECIPIENT ;
|
||||
|
||||
if (!lhSession || pNsMapi->IsValidSession(lhSession) != S_OK)
|
||||
{
|
||||
FLAGS LoginFlag ;
|
||||
if ( (flFlags & MAPI_LOGON_UI) && (flFlags & MAPI_NEW_SESSION) )
|
||||
LoginFlag = MAPI_LOGON_UI | MAPI_NEW_SESSION ;
|
||||
else if (flFlags & MAPI_LOGON_UI)
|
||||
LoginFlag = MAPI_LOGON_UI ;
|
||||
|
||||
hr = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, LoginFlag, 0, &lhSession) ;
|
||||
if (hr != SUCCESS_SUCCESS)
|
||||
return MAPI_E_LOGIN_FAILURE ;
|
||||
bTempSession = TRUE ;
|
||||
}
|
||||
|
||||
// we need to deal with null data passed in by MAPI clients, specially when MAPI_DIALOG is set.
|
||||
// The MS COM type lib code generated by MIDL for the MS COM interfaces checks for these parameters
|
||||
// to be non null, although null is a valid value for them here.
|
||||
nsMapiRecipDesc * lpRecips ;
|
||||
nsMapiFileDesc * lpFiles ;
|
||||
|
||||
nsMapiMessage Message ;
|
||||
memset (&Message, 0, sizeof (nsMapiMessage) ) ;
|
||||
nsMapiRecipDesc Recipient ;
|
||||
memset (&Recipient, 0, sizeof (nsMapiRecipDesc) );
|
||||
nsMapiFileDesc Files ;
|
||||
memset (&Files, 0, sizeof (nsMapiFileDesc) ) ;
|
||||
|
||||
if(!lpMessage)
|
||||
{
|
||||
lpMessage = &Message ;
|
||||
}
|
||||
if(!lpMessage->lpRecips)
|
||||
{
|
||||
lpRecips = &Recipient ;
|
||||
}
|
||||
else
|
||||
lpRecips = lpMessage->lpRecips ;
|
||||
if(!lpMessage->lpFiles)
|
||||
{
|
||||
lpFiles = &Files ;
|
||||
}
|
||||
else
|
||||
lpFiles = lpMessage->lpFiles ;
|
||||
|
||||
HANDLE hEvent = CreateEvent (NULL, FALSE, FALSE, (LPCTSTR) MAPI_SENDCOMPLETE_EVENT) ;
|
||||
|
||||
hr = pNsMapi->SendMail (lhSession, lpMessage,
|
||||
(short) lpMessage->nRecipCount, lpRecips,
|
||||
(short) lpMessage->nFileCount, lpFiles,
|
||||
flFlags, ulReserved);
|
||||
|
||||
// we are seeing a problem when using Word, although we return success from the MAPI support
|
||||
// MS COM interface in mozilla, we are getting this error here. This is a temporary hack !!
|
||||
if (hr == 0x800703e6)
|
||||
hr = SUCCESS_SUCCESS;
|
||||
|
||||
if (hr == SUCCESS_SUCCESS)
|
||||
WaitForSingleObject (hEvent, INFINITE) ;
|
||||
CloseHandle (hEvent) ;
|
||||
|
||||
if (bTempSession)
|
||||
MAPILogoff (lhSession, ulUIParam, 0,0) ;
|
||||
|
||||
return hr ;
|
||||
}
|
||||
|
||||
|
||||
ULONG FAR PASCAL MAPISendDocuments(ULONG ulUIParam, LPTSTR lpszDelimChar, LPTSTR lpszFilePaths,
|
||||
LPTSTR lpszFileNames, ULONG ulReserved)
|
||||
{
|
||||
LHANDLE lhSession ;
|
||||
nsIMapi *pNsMapi = NULL;
|
||||
|
||||
if (!InitMozillaReference(&pNsMapi))
|
||||
return MAPI_E_FAILURE;
|
||||
|
||||
unsigned long result = MAPILogon (ulUIParam, (LPTSTR) NULL, (LPTSTR) NULL, MAPI_LOGON_UI, 0, &lhSession) ;
|
||||
if (result != SUCCESS_SUCCESS)
|
||||
return MAPI_E_LOGIN_FAILURE ;
|
||||
|
||||
HRESULT hr;
|
||||
|
||||
HANDLE hEvent = CreateEvent (NULL, FALSE, FALSE, (LPCTSTR) MAPI_SENDCOMPLETE_EVENT) ;
|
||||
|
||||
hr = pNsMapi->SendDocuments(lhSession, (LPTSTR) lpszDelimChar, (LPTSTR) lpszFilePaths,
|
||||
(LPTSTR) lpszFileNames, ulReserved) ;
|
||||
|
||||
if (hr == SUCCESS_SUCCESS)
|
||||
WaitForSingleObject (hEvent, INFINITE) ;
|
||||
CloseHandle (hEvent) ;
|
||||
|
||||
MAPILogoff (lhSession, ulUIParam, 0,0) ;
|
||||
|
||||
return hr ;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIFindNext(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageType,
|
||||
LPTSTR lpszSeedMessageID, FLAGS flFlags, ULONG ulReserved,
|
||||
LPTSTR lpszMessageID)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIReadMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
|
||||
FLAGS flFlags, ULONG ulReserved, lpMapiMessage FAR *lppMessage)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPISaveMail(LHANDLE lhSession, ULONG ulUIParam, lpMapiMessage lpMessage,
|
||||
FLAGS flFlags, ULONG ulReserved, LPTSTR lpszMessageID)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIDeleteMail(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszMessageID,
|
||||
FLAGS flFlags, ULONG ulReserved)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIAddress(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszCaption,
|
||||
ULONG nEditFields, LPTSTR lpszLabels, ULONG nRecips,
|
||||
lpMapiRecipDesc lpRecips, FLAGS flFlags,
|
||||
ULONG ulReserved, LPULONG lpnNewRecips,
|
||||
lpMapiRecipDesc FAR *lppNewRecips)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIDetails(LHANDLE lhSession, ULONG ulUIParam, lpMapiRecipDesc lpRecip,
|
||||
FLAGS flFlags, ULONG ulReserved)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIResolveName(LHANDLE lhSession, ULONG ulUIParam, LPTSTR lpszName,
|
||||
FLAGS flFlags, ULONG ulReserved, lpMapiRecipDesc FAR *lppRecip)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL MAPIFreeBuffer(LPVOID pv)
|
||||
{
|
||||
return MAPI_E_FAILURE;
|
||||
}
|
||||
|
||||
ULONG FAR PASCAL GetMapiDllVersion()
|
||||
{
|
||||
return 94;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
MODULE = mozMapi32
|
||||
EXPORT_LIBRARY = $(MODULE)
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
DEFFILE = Mapi32.def
|
||||
|
||||
REQUIRES = MapiProxy \
|
||||
msgMapi \
|
||||
xpcom \
|
||||
string \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
###############################################################
|
||||
|
||||
LCFLAGS=-DUNICODE -D_UNICODE
|
||||
|
||||
OBJS= .\$(OBJDIR)\MapiDll.obj \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS= ole32.lib \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
; ***** BEGIN LICENSE BLOCK *****
|
||||
; Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
;
|
||||
; The contents of this file are subject to the Mozilla Public License Version
|
||||
; 1.1 (the "License"); you may not use this file except in compliance with
|
||||
; the License. You may obtain a copy of the License at
|
||||
; http://www.mozilla.org/MPL/
|
||||
;
|
||||
; Software distributed under the License is distributed on an "AS IS" basis,
|
||||
; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
; for the specific language governing rights and limitations under the
|
||||
; License.
|
||||
;
|
||||
; The Original Code is Mozilla.
|
||||
;
|
||||
; The Initial Developer of the Original Code is
|
||||
; Netscape Communications Corp.
|
||||
; Portions created by the Initial Developer are Copyright (C) 2001
|
||||
; the Initial Developer. All Rights Reserved.
|
||||
;
|
||||
; Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
;
|
||||
; Alternatively, the contents of this file may be used under the terms of
|
||||
; either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
; in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
; of those above. If you wish to allow use of your version of this file only
|
||||
; under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
; use your version of this file under the terms of the MPL, indicate your
|
||||
; decision by deleting the provisions above and replace them with the notice
|
||||
; and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
; the provisions above, a recipient may use your version of this file under
|
||||
; the terms of any one of the MPL, the GPL or the LGPL.
|
||||
;
|
||||
; ***** END LICENSE BLOCK *****
|
||||
|
||||
LIBRARY MapiProxy.dll
|
||||
DESCRIPTION 'Proxy/Stub DLL'
|
||||
|
||||
EXPORTS
|
||||
DllGetClassObject @1 PRIVATE
|
||||
DllCanUnloadNow @2 PRIVATE
|
||||
GetProxyDllInfo @3 PRIVATE
|
||||
DllRegisterServer @4 PRIVATE
|
||||
DllUnregisterServer @5 PRIVATE
|
||||
|
||||
|
||||
@@ -1,68 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MODULE = MapiProxy
|
||||
EXPORT_LIBRARY = $(MODULE)
|
||||
LIBRARY_NAME = $(MODULE)
|
||||
DEFFILE = MapiProxy.def
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
|
||||
##################################################################
|
||||
|
||||
LCFLAGS=-DREGISTER_PROXY_DLL -DUNICODE -D_UNICODE
|
||||
|
||||
OBJS= .\$(OBJDIR)\dlldata.obj \
|
||||
.\$(OBJDIR)\msgMapi_p.obj \
|
||||
.\$(OBJDIR)\msgMapi_i.obj \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS= rpcrt4.lib
|
||||
|
||||
EXPORTS= msgMapi.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
msgMapi.h msgMapi_p.c msgMapi_i.c dlldata.c : msgMapi.idl
|
||||
midl $(UNICODE_FLAGS) msgMapi.idl
|
||||
|
||||
clobber::
|
||||
rm -f dlldata.c msgMapi_i.c msgMapi_p.c msgMapi.h
|
||||
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
* Contributor(s): Rajiv Dayal (rdayal@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
// This idl will be compiled by MIDL. MS-COM is used
|
||||
// as brdige between MAPI clients and the Mozilla.
|
||||
|
||||
import "unknwn.idl";
|
||||
|
||||
typedef wchar_t LOGIN_PW_TYPE[256];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long ulReserved;
|
||||
unsigned long flFlags; /* Flags */
|
||||
unsigned long nPosition_NotUsed; /* character in text to be replaced by attachment */
|
||||
LPTSTR lpszPathName; /* Full path name including file name */
|
||||
LPTSTR lpszFileName; /* Real (original) file name */
|
||||
unsigned char * lpFileType_NotUsed ;
|
||||
} nsMapiFileDesc, * lpnsMapiFileDesc;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long ulReserved;
|
||||
unsigned long ulRecipClass; /* MAPI_TO, MAPI_CC, MAPI_BCC, MAPI_ORIG */
|
||||
LPTSTR lpszName; /* Recipient name to display */
|
||||
LPTSTR lpszAddress; /* Recipient email address */
|
||||
unsigned long ulEIDSize_NotUsed;
|
||||
unsigned char * lpEntryID_NotUsed ;
|
||||
} nsMapiRecipDesc, * lpnsMapiRecipDesc;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned long ulReserved;
|
||||
LPTSTR lpszSubject; /* Message Subject */
|
||||
LPTSTR lpszNoteText; /* Message Text */
|
||||
LPTSTR lpszMessageType_NotUsed;
|
||||
LPTSTR lpszDateReceived_notUsed; /* in YYYY/MM/DD HH:MM format */
|
||||
LPTSTR lpszConversationID_NotUsed; /* conversation thread ID */
|
||||
unsigned long flFlags; /* unread,return receipt */
|
||||
lpnsMapiRecipDesc lpOriginator; /* Originator descriptor */
|
||||
unsigned long nRecipCount; /* Number of recipients */
|
||||
lpnsMapiRecipDesc lpRecips; /* Recipient descriptors */
|
||||
unsigned long nFileCount; /* # of file attachments */
|
||||
lpnsMapiFileDesc lpFiles; /* Attachment descriptors */
|
||||
} nsMapiMessage, * lpnsMapiMessage;
|
||||
|
||||
|
||||
[
|
||||
object,
|
||||
uuid(6EDCD38E-8861-11d5-A3DD-00B0D0F3BAA7),
|
||||
helpstring("nsIMapi Inteface"),
|
||||
pointer_default(unique)
|
||||
]
|
||||
|
||||
interface nsIMapi : IUnknown
|
||||
{
|
||||
HRESULT Login(unsigned long aUIArg, LOGIN_PW_TYPE aLogin,
|
||||
LOGIN_PW_TYPE aPassWord, unsigned long aFlags,
|
||||
[out] unsigned long *aSessionId);
|
||||
|
||||
HRESULT Initialize();
|
||||
HRESULT IsValid();
|
||||
HRESULT IsValidSession([in] unsigned long aSession);
|
||||
|
||||
HRESULT SendMail([in] unsigned long aSession, [in] lpnsMapiMessage aMessage,
|
||||
[in] short aRecipCount, [in, size_is(aRecipCount)] lpnsMapiRecipDesc aRecips,
|
||||
[in] short aFileCount, [in, size_is(aFileCount)] lpnsMapiFileDesc aFiles,
|
||||
[in] unsigned long aFlags, [in] unsigned long aReserved) ;
|
||||
|
||||
HRESULT SendDocuments( [in] unsigned long aSession,
|
||||
[in] LPTSTR aDelimChar, [in] LPTSTR aFilePaths,
|
||||
[in] LPTSTR aFileNames, [in] ULONG aFlags ) ;
|
||||
|
||||
HRESULT Logoff (unsigned long aSession);
|
||||
HRESULT CleanUp();
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is Mozilla.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s): Srilatha Moturi (srilatha@netscape.com)
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS= build public src
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,49 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MODULE=msgMapi
|
||||
XPIDL_MODULE=mapihook
|
||||
|
||||
XPIDLSRCS = \
|
||||
.\nsIMapiRegistry.idl \
|
||||
.\nsIMapiSupport.idl \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDOMWindow;
|
||||
|
||||
/**
|
||||
* This interface provides support for registering Mozilla as the default
|
||||
* Mail Client. This interface can also be used to get/set the user preference
|
||||
* for the default Mail Client.
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(c5be14ba-4e0a-4eec-a1b8-04363761d63c)]
|
||||
interface nsIMapiRegistry: nsISupports {
|
||||
|
||||
/** This is set to TRUE if Mozilla is the default Application
|
||||
*/
|
||||
attribute boolean isDefaultMailClient;
|
||||
|
||||
/** This is set TRUE only once per session.
|
||||
*/
|
||||
readonly attribute boolean showDialog;
|
||||
|
||||
/** This will bring the dialog asking the user if he/she wants to set
|
||||
* Mozilla as default Mail Client.
|
||||
* Call this only if Mozilla is not the default Mail client
|
||||
*/
|
||||
void showMailIntegrationDialog(in nsIDOMWindow parentWindow);
|
||||
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IMAPIREGISTRY_CONTRACTID "@mozilla.org/mapiregistry;1"
|
||||
#define NS_IMAPIREGISTRY_CLASSNAME "Mozilla MAPI Registry"
|
||||
%}
|
||||
@@ -1,64 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* This interface provides support for registering Mozilla as a COM component
|
||||
* for extending the use of Mail/News through Simple MAPI.
|
||||
*
|
||||
*/
|
||||
|
||||
[noscript, uuid(8967fed2-c8bb-11d5-a3e9-00b0d0f3baa7)]
|
||||
interface nsIMapiSupport : nsISupports {
|
||||
|
||||
/** Initiates MAPI support
|
||||
*/
|
||||
|
||||
void initializeMAPISupport();
|
||||
|
||||
/** Shuts down the MAPI support
|
||||
*/
|
||||
|
||||
void shutdownMAPISupport();
|
||||
};
|
||||
|
||||
%{C++
|
||||
#define NS_IMAPISUPPORT_CONTRACTID "@mozilla.org/mapisupport;1"
|
||||
#define NS_IMAPISUPPORT_CLASSNAME "Mozilla MAPI Support"
|
||||
%}
|
||||
|
||||
|
||||
@@ -1,323 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika <kkhandrika@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#undef _UNICODE
|
||||
#undef UNICODE
|
||||
|
||||
#include <objbase.h>
|
||||
#include "nsString.h"
|
||||
#include "Registry.h"
|
||||
|
||||
#define MAPI_PROXY_DLL_NAME "MapiProxy.dll"
|
||||
#define MAPI_STARTUP_ARG " /MAPIStartUp"
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
// Size of a CLSID as a string
|
||||
const int CLSID_STRING_SIZE = 39;
|
||||
|
||||
// Proxy/Stub Dll Routines
|
||||
|
||||
typedef HRESULT (__stdcall ProxyServer)();
|
||||
|
||||
|
||||
// Convert a CLSID to a char string.
|
||||
|
||||
BOOL CLSIDtochar(const CLSID& clsid, char* szCLSID,
|
||||
int length)
|
||||
{
|
||||
LPOLESTR wszCLSID = NULL;
|
||||
|
||||
// Get CLSID
|
||||
HRESULT hr = StringFromCLSID(clsid, &wszCLSID);
|
||||
if (FAILED(hr))
|
||||
return FALSE;
|
||||
|
||||
// Covert from wide characters to non-wide.
|
||||
wcstombs(szCLSID, wszCLSID, length);
|
||||
|
||||
// Free memory.
|
||||
CoTaskMemFree(wszCLSID);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Create a key and set its value.
|
||||
|
||||
BOOL setKeyAndValue(nsCAutoString keyName, const char* subKey,
|
||||
const char* theValue)
|
||||
{
|
||||
HKEY hKey;
|
||||
BOOL retValue = TRUE;
|
||||
|
||||
nsCAutoString theKey(keyName);
|
||||
if (subKey != NULL)
|
||||
{
|
||||
theKey += "\\";
|
||||
theKey += subKey;
|
||||
}
|
||||
|
||||
// Create and open key and subkey.
|
||||
long lResult = RegCreateKeyEx(HKEY_CLASSES_ROOT, theKey.get(),
|
||||
0, NULL, REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
return FALSE ;
|
||||
|
||||
// Set the Value.
|
||||
if (theValue != NULL)
|
||||
{
|
||||
lResult = RegSetValueEx(hKey, NULL, 0, REG_SZ, (BYTE *)theValue,
|
||||
strlen(theValue)+1);
|
||||
if (lResult != ERROR_SUCCESS)
|
||||
retValue = FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Delete a key and all of its descendents.
|
||||
|
||||
LONG recursiveDeleteKey(HKEY hKeyParent, // Parent of key to delete
|
||||
const char* lpszKeyChild) // Key to delete
|
||||
{
|
||||
// Open the child.
|
||||
HKEY hKeyChild ;
|
||||
LONG lRes = RegOpenKeyEx(hKeyParent, lpszKeyChild, 0,
|
||||
KEY_ALL_ACCESS, &hKeyChild) ;
|
||||
if (lRes != ERROR_SUCCESS)
|
||||
{
|
||||
return lRes ;
|
||||
}
|
||||
|
||||
// Enumerate all of the decendents of this child.
|
||||
FILETIME time ;
|
||||
char szBuffer[MAX_SIZE] ;
|
||||
DWORD dwSize = MAX_SIZE ;
|
||||
while (RegEnumKeyEx(hKeyChild, 0, szBuffer, &dwSize, NULL,
|
||||
NULL, NULL, &time) == S_OK)
|
||||
{
|
||||
// Delete the decendents of this child.
|
||||
lRes = recursiveDeleteKey(hKeyChild, szBuffer) ;
|
||||
if (lRes != ERROR_SUCCESS)
|
||||
{
|
||||
// Cleanup before exiting.
|
||||
RegCloseKey(hKeyChild) ;
|
||||
return lRes;
|
||||
}
|
||||
dwSize = MAX_SIZE;
|
||||
}
|
||||
|
||||
// Close the child.
|
||||
RegCloseKey(hKeyChild) ;
|
||||
|
||||
// Delete this child.
|
||||
return RegDeleteKey(hKeyParent, lpszKeyChild) ;
|
||||
}
|
||||
|
||||
void RegisterProxy()
|
||||
{
|
||||
HINSTANCE h = NULL;
|
||||
ProxyServer *RegisterFunc = NULL;
|
||||
|
||||
char szModule[MAX_SIZE];
|
||||
char *pTemp = NULL;
|
||||
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModule,
|
||||
sizeof(szModule)/sizeof(char));
|
||||
if (dwResult == 0)
|
||||
return;
|
||||
|
||||
pTemp = strrchr(szModule, '\\');
|
||||
if (pTemp == NULL)
|
||||
return;
|
||||
|
||||
*pTemp = '\0';
|
||||
nsCAutoString proxyPath(szModule);
|
||||
|
||||
proxyPath += "\\";
|
||||
proxyPath += MAPI_PROXY_DLL_NAME;
|
||||
|
||||
h = LoadLibrary(proxyPath.get());
|
||||
if (h == NULL)
|
||||
return;
|
||||
|
||||
RegisterFunc = (ProxyServer *) GetProcAddress(h, "DllRegisterServer");
|
||||
if (RegisterFunc)
|
||||
RegisterFunc();
|
||||
|
||||
FreeLibrary(h);
|
||||
}
|
||||
|
||||
void UnRegisterProxy()
|
||||
{
|
||||
HINSTANCE h = NULL;
|
||||
ProxyServer *UnRegisterFunc = NULL;
|
||||
|
||||
char szModule[MAX_SIZE];
|
||||
char *pTemp = NULL;
|
||||
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModule,
|
||||
sizeof(szModule)/sizeof(char));
|
||||
if (dwResult == 0)
|
||||
return;
|
||||
|
||||
pTemp = strrchr(szModule, '\\');
|
||||
if (pTemp == NULL)
|
||||
return;
|
||||
|
||||
*pTemp = '\0';
|
||||
nsCAutoString proxyPath(szModule);
|
||||
|
||||
proxyPath += "\\";
|
||||
proxyPath += MAPI_PROXY_DLL_NAME;
|
||||
|
||||
h = LoadLibrary(proxyPath.get());
|
||||
if (h == NULL)
|
||||
return;
|
||||
|
||||
UnRegisterFunc = (ProxyServer *) GetProcAddress(h, "DllUnregisterServer");
|
||||
if (UnRegisterFunc)
|
||||
UnRegisterFunc();
|
||||
|
||||
FreeLibrary(h);
|
||||
}
|
||||
|
||||
// Register the component in the registry.
|
||||
|
||||
HRESULT RegisterServer(const CLSID& clsid, // Class ID
|
||||
const char* szFriendlyName, // Friendly Name
|
||||
const char* szVerIndProgID, // Programmatic
|
||||
const char* szProgID) // IDs
|
||||
{
|
||||
HMODULE hModule = GetModuleHandle(NULL);
|
||||
char szModuleName[MAX_SIZE];
|
||||
char szCLSID[CLSID_STRING_SIZE];
|
||||
|
||||
nsCAutoString independentProgId(szVerIndProgID);
|
||||
nsCAutoString progId(szProgID);
|
||||
|
||||
DWORD dwResult = ::GetModuleFileName(hModule, szModuleName,
|
||||
sizeof(szModuleName)/sizeof(char));
|
||||
|
||||
if (dwResult == 0)
|
||||
return S_FALSE;
|
||||
|
||||
nsCAutoString moduleName(szModuleName);
|
||||
nsCAutoString registryKey("CLSID\\");
|
||||
|
||||
moduleName += MAPI_STARTUP_ARG;
|
||||
|
||||
// Convert the CLSID into a char.
|
||||
|
||||
if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
|
||||
return S_FALSE;
|
||||
registryKey += szCLSID;
|
||||
|
||||
// Add the CLSID to the registry.
|
||||
if (!setKeyAndValue(registryKey, NULL, szFriendlyName))
|
||||
return S_FALSE;
|
||||
|
||||
if (!setKeyAndValue(registryKey, "LocalServer32", moduleName.get()))
|
||||
return S_FALSE;
|
||||
|
||||
// Add the ProgID subkey under the CLSID key.
|
||||
if (!setKeyAndValue(registryKey, "ProgID", szProgID))
|
||||
return S_FALSE;
|
||||
|
||||
// Add the version-independent ProgID subkey under CLSID key.
|
||||
if (!setKeyAndValue(registryKey, "VersionIndependentProgID", szVerIndProgID))
|
||||
return S_FALSE;
|
||||
|
||||
// Add the version-independent ProgID subkey under HKEY_CLASSES_ROOT.
|
||||
if (!setKeyAndValue(independentProgId, NULL, szFriendlyName))
|
||||
return S_FALSE;
|
||||
if (!setKeyAndValue(independentProgId, "CLSID", szCLSID))
|
||||
return S_FALSE;
|
||||
if (!setKeyAndValue(independentProgId, "CurVer", szProgID))
|
||||
return S_FALSE;
|
||||
|
||||
// Add the versioned ProgID subkey under HKEY_CLASSES_ROOT.
|
||||
if (!setKeyAndValue(progId, NULL, szFriendlyName))
|
||||
return S_FALSE;
|
||||
if (!setKeyAndValue(progId, "CLSID", szCLSID))
|
||||
return S_FALSE;
|
||||
|
||||
RegisterProxy();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
LONG UnregisterServer(const CLSID& clsid, // Class ID
|
||||
const char* szVerIndProgID, // Programmatic
|
||||
const char* szProgID) // IDs
|
||||
{
|
||||
LONG lResult = S_OK;
|
||||
|
||||
// Convert the CLSID into a char.
|
||||
|
||||
char szCLSID[CLSID_STRING_SIZE];
|
||||
if (!CLSIDtochar(clsid, szCLSID, sizeof(szCLSID)))
|
||||
return S_FALSE;
|
||||
|
||||
UnRegisterProxy();
|
||||
|
||||
nsCAutoString registryKey("CLSID\\");
|
||||
registryKey += szCLSID;
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
|
||||
if (lResult == ERROR_SUCCESS || lResult == ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
registryKey += "\\LocalServer32";
|
||||
|
||||
// Delete only the path for this server.
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, registryKey.get());
|
||||
if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
// Delete the version-independent ProgID Key.
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szVerIndProgID);
|
||||
if (lResult != ERROR_SUCCESS && lResult != ERROR_FILE_NOT_FOUND)
|
||||
return lResult;
|
||||
|
||||
lResult = recursiveDeleteKey(HKEY_CLASSES_ROOT, szProgID);
|
||||
|
||||
return lResult;
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Krishna Mohan Khandrika <kkhandrika@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef _REGISTRY_H_
|
||||
#define _REGISTRY_H_
|
||||
|
||||
#include <objbase.h>
|
||||
|
||||
// This function will register a component in the Registry.
|
||||
|
||||
HRESULT RegisterServer(const CLSID& clsid,
|
||||
const char* szFriendlyName,
|
||||
const char* szVerIndProgID,
|
||||
const char* szProgID) ;
|
||||
|
||||
// This function will unregister a component.
|
||||
|
||||
HRESULT UnregisterServer(const CLSID& clsid,
|
||||
const char* szVerIndProgID,
|
||||
const char* szProgID) ;
|
||||
|
||||
#endif
|
||||
@@ -1,107 +0,0 @@
|
||||
# ***** BEGIN LICENSE BLOCK *****
|
||||
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public License Version
|
||||
# 1.1 (the "License"); you may not use this file except in compliance with
|
||||
# the License. You may obtain a copy of the License at
|
||||
# http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
# for the specific language governing rights and limitations under the
|
||||
# License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corporation.
|
||||
# Portions created by the Initial Developer are Copyright (C) 2001
|
||||
# the Initial Developer. All Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
# Alternatively, the contents of this file may be used under the terms of
|
||||
# either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
# in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
# of those above. If you wish to allow use of your version of this file only
|
||||
# under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
# use your version of this file under the terms of the MPL, indicate your
|
||||
# decision by deleting the provisions above and replace them with the notice
|
||||
# and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
# the provisions above, a recipient may use your version of this file under
|
||||
# the terms of any one of the MPL, the GPL or the LGPL.
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
MODULE = msgMapi
|
||||
MAKE_OBJ_TYPE = DLL
|
||||
LIBRARY_NAME=$(MODULE)
|
||||
MODULE_NAME = $(MODULE)
|
||||
|
||||
REQUIRES = xpcom \
|
||||
string \
|
||||
MapiProxy \
|
||||
appshell \
|
||||
windowwatcher \
|
||||
dom \
|
||||
profile \
|
||||
msgbase \
|
||||
pref \
|
||||
msgbaseutil \
|
||||
msgcompo \
|
||||
mailnews \
|
||||
necko \
|
||||
intl \
|
||||
editor \
|
||||
msgdb \
|
||||
uriloader \
|
||||
appstartup \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\config.mak>
|
||||
############################################################################
|
||||
|
||||
LCFLAGS=-DUNICODE -D_UNICODE
|
||||
|
||||
|
||||
|
||||
OBJS= \
|
||||
..\build\$(OBJDIR)\msgMapi_i.obj \
|
||||
.\$(OBJDIR)\msgMapiFactory.obj \
|
||||
.\$(OBJDIR)\msgMapiHook.obj \
|
||||
.\$(OBJDIR)\msgMapiImp.obj \
|
||||
.\$(OBJDIR)\msgMapiMain.obj \
|
||||
.\$(OBJDIR)\msgMapiSupport.obj \
|
||||
.\$(OBJDIR)\nsMapiRegistry.obj \
|
||||
.\$(OBJDIR)\nsMapiRegistryUtils.obj \
|
||||
.\$(OBJDIR)\Registry.obj \
|
||||
$(NULL)
|
||||
|
||||
|
||||
|
||||
LLIBS= \
|
||||
$(DIST)\lib\xpcom.lib \
|
||||
$(DIST)\lib\msgbsutl.lib \
|
||||
$(LIBNSPR) \
|
||||
$(NULL)
|
||||
|
||||
WIN_LIBS= \
|
||||
ole32.lib \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS= \
|
||||
msgMapiFactory.h \
|
||||
msgMapiHook.h \
|
||||
msgMapiImp.h \
|
||||
msgMapiMain.h \
|
||||
msgMapiSupport.h \
|
||||
nsMapiRegistry.h \
|
||||
nsMapiRegistryUtils.h \
|
||||
Registry.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,118 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#undef UNICODE
|
||||
#undef _UNICODE
|
||||
|
||||
#include "msgMapiFactory.h"
|
||||
#include "msgMapiImp.h"
|
||||
#include "msgMapi.h"
|
||||
|
||||
CMapiFactory ::CMapiFactory()
|
||||
: m_cRef(1)
|
||||
{
|
||||
}
|
||||
|
||||
CMapiFactory::~CMapiFactory()
|
||||
{
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiFactory::QueryInterface(const IID& aIid, void** aPpv)
|
||||
{
|
||||
if ((aIid == IID_IUnknown) || (aIid == IID_IClassFactory))
|
||||
{
|
||||
*aPpv = static_cast<IClassFactory*>(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aPpv = nsnull;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
reinterpret_cast<IUnknown*>(*aPpv)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CMapiFactory::AddRef()
|
||||
{
|
||||
return (PR_AtomicIncrement(&m_cRef));
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CMapiFactory::Release()
|
||||
{
|
||||
PRInt32 temp;
|
||||
temp = PR_AtomicDecrement(&m_cRef);
|
||||
if (m_cRef == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiFactory::CreateInstance(IUnknown* aUnknownOuter,
|
||||
const IID& aIid,
|
||||
void** aPpv)
|
||||
{
|
||||
// Cannot aggregate.
|
||||
|
||||
if (aUnknownOuter != nsnull)
|
||||
{
|
||||
return CLASS_E_NOAGGREGATION ;
|
||||
}
|
||||
|
||||
// Create component.
|
||||
|
||||
CMapiImp* pImp = new CMapiImp();
|
||||
if (pImp == nsnull)
|
||||
{
|
||||
return E_OUTOFMEMORY ;
|
||||
}
|
||||
|
||||
// Get the requested interface.
|
||||
HRESULT hr = pImp->QueryInterface(aIid, aPpv);
|
||||
|
||||
// Release the IUnknown pointer.
|
||||
// (If QueryInterface failed, component will delete itself.)
|
||||
|
||||
pImp->Release();
|
||||
return hr;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiFactory::LockServer(PRBool aLock)
|
||||
{
|
||||
return S_OK ;
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MSG_MAPI_FACTORY_H
|
||||
#define MSG_MAPI_FACTORY_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <objbase.h>
|
||||
#include "nspr.h"
|
||||
|
||||
|
||||
class CMapiFactory : public IClassFactory
|
||||
{
|
||||
public :
|
||||
|
||||
// IUnknown
|
||||
|
||||
STDMETHODIMP QueryInterface (REFIID aIid, void** aPpv);
|
||||
STDMETHODIMP_(ULONG) AddRef(void);
|
||||
STDMETHODIMP_(ULONG) Release(void);
|
||||
|
||||
// IClassFactory
|
||||
|
||||
STDMETHODIMP CreateInstance (LPUNKNOWN aUnkOuter, REFIID aIid, void **aPpv);
|
||||
STDMETHODIMP LockServer (BOOL aLock);
|
||||
|
||||
CMapiFactory ();
|
||||
~CMapiFactory ();
|
||||
|
||||
private :
|
||||
|
||||
PRInt32 m_cRef;
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_FACTORY_H
|
||||
|
||||
@@ -1,777 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
* Contributor(s): Srilatha Moturi (srilatha@netscape.com)
|
||||
* Contributor(s): Rajiv Dayal (rdayal@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#define MAPI_STARTUP_ARG "/MAPIStartUp"
|
||||
|
||||
#define MAPI_STARTUP_ARG "/MAPIStartUp"
|
||||
|
||||
#include <mapidefs.h>
|
||||
#include <mapi.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsAppShellCIDs.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIAppShellService.h"
|
||||
#include "nsINativeAppSupport.h"
|
||||
#include "nsICmdLineService.h"
|
||||
#include "nsIProfileInternal.h"
|
||||
#include "nsIMsgAccountManager.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsMsgBaseCID.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIPref.h"
|
||||
#include "nsString.h"
|
||||
|
||||
#include "nsIMsgAttachment.h"
|
||||
#include "nsIMsgCompFields.h"
|
||||
#include "nsIMsgComposeParams.h"
|
||||
#include "nsIMsgCompose.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
#include "nsIMsgSend.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsIMsgComposeService.h"
|
||||
#include "nsProxiedService.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsMsgI18N.h"
|
||||
|
||||
#include "msgMapi.h"
|
||||
#include "msgMapiHook.h"
|
||||
#include "msgMapiSupport.h"
|
||||
#include "msgMapiMain.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
static NS_DEFINE_CID(kCmdLineServiceCID, NS_COMMANDLINE_SERVICE_CID);
|
||||
|
||||
class nsMAPISendListener : public nsIMsgSendListener
|
||||
{
|
||||
public:
|
||||
|
||||
virtual ~nsMAPISendListener() { }
|
||||
|
||||
// nsISupports interface
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
/* void OnStartSending (in string aMsgID, in PRUint32 aMsgSize); */
|
||||
NS_IMETHOD OnStartSending(const char *aMsgID, PRUint32 aMsgSize) { return NS_OK; }
|
||||
|
||||
/* void OnProgress (in string aMsgID, in PRUint32 aProgress, in PRUint32 aProgressMax); */
|
||||
NS_IMETHOD OnProgress(const char *aMsgID, PRUint32 aProgress, PRUint32 aProgressMax) { return NS_OK;}
|
||||
|
||||
/* void OnStatus (in string aMsgID, in wstring aMsg); */
|
||||
NS_IMETHOD OnStatus(const char *aMsgID, const PRUnichar *aMsg) { return NS_OK;}
|
||||
|
||||
/* void OnStopSending (in string aMsgID, in nsresult aStatus, in wstring aMsg, in nsIFileSpec returnFileSpec); */
|
||||
NS_IMETHOD OnStopSending(const char *aMsgID, nsresult aStatus, const PRUnichar *aMsg,
|
||||
nsIFileSpec *returnFileSpec) {
|
||||
m_done = PR_TRUE;
|
||||
HANDLE hEvent = CreateEvent (NULL, FALSE, FALSE, (LPCTSTR) MAPI_SENDCOMPLETE_EVENT) ;
|
||||
SetEvent (hEvent) ;
|
||||
CloseHandle (hEvent) ;
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
/* void OnSendNotPerformed */
|
||||
NS_IMETHOD OnSendNotPerformed(const char *aMsgID, nsresult aStatus)
|
||||
{
|
||||
return OnStopSending(aMsgID, aStatus, nsnull, nsnull) ;
|
||||
}
|
||||
|
||||
/* void OnGetDraftFolderURI (); */
|
||||
NS_IMETHOD OnGetDraftFolderURI(const char *aFolderURI) {return NS_OK;}
|
||||
|
||||
static nsresult CreateMAPISendListener( nsIMsgSendListener **ppListener);
|
||||
|
||||
PRBool IsDone() { return m_done ; }
|
||||
|
||||
protected :
|
||||
nsMAPISendListener() {
|
||||
NS_INIT_REFCNT();
|
||||
m_done = PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool m_done;
|
||||
};
|
||||
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsMAPISendListener, nsIMsgSendListener)
|
||||
|
||||
nsresult nsMAPISendListener::CreateMAPISendListener( nsIMsgSendListener **ppListener)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(ppListener) ;
|
||||
|
||||
*ppListener = new nsMAPISendListener();
|
||||
if (! *ppListener)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ADDREF(*ppListener);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool nsMapiHook::isMapiService = PR_FALSE;
|
||||
|
||||
PRBool nsMapiHook::Initialize()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsINativeAppSupport> native;
|
||||
|
||||
nsCOMPtr<nsICmdLineService> cmdLineArgs(do_GetService(kCmdLineServiceCID, &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell (do_GetService( "@mozilla.org/appshell/appShellService;1", &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
rv = appShell->GetNativeAppSupport( getter_AddRefs( native ));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
rv = native->EnsureProfile(cmdLineArgs);
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
void nsMapiHook::CleanUp()
|
||||
{
|
||||
// This routine will be fully implemented in future
|
||||
// to cleanup mapi related stuff inside mozilla code.
|
||||
}
|
||||
|
||||
PRBool nsMapiHook::DisplayLoginDialog(PRBool aLogin, PRUnichar **aUsername, \
|
||||
PRUnichar **aPassword)
|
||||
{
|
||||
nsresult rv;
|
||||
PRBool btnResult = PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIAppShellService> appShell(do_GetService( "@mozilla.org/appshell/appShellService;1", &rv));
|
||||
if (NS_FAILED(rv) || !appShell) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPromptService> dlgService(do_GetService("@mozilla.org/embedcomp/prompt-service;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && dlgService)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || !bundleService) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(bundle));
|
||||
if (NS_FAILED(rv) || !bundle) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle(
|
||||
"chrome://global/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsXPIDLString brandName;
|
||||
rv = brandBundle->GetStringFromName(
|
||||
NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsXPIDLString loginTitle;
|
||||
const PRUnichar *brandStrings[] = { brandName.get() };
|
||||
NS_NAMED_LITERAL_STRING(loginTitlePropertyTag, "loginTitle");
|
||||
const PRUnichar *dTitlePropertyTag = loginTitlePropertyTag.get();
|
||||
rv = bundle->FormatStringFromName(dTitlePropertyTag, brandStrings, 1,
|
||||
getter_Copies(loginTitle));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
if (aLogin)
|
||||
{
|
||||
nsXPIDLString loginText;
|
||||
rv = bundle->GetStringFromName(NS_LITERAL_STRING("loginTextwithName").get(),
|
||||
getter_Copies(loginText));
|
||||
if (NS_FAILED(rv) || !loginText) return PR_FALSE;
|
||||
|
||||
|
||||
|
||||
rv = dlgService->PromptUsernameAndPassword(nsnull, loginTitle,
|
||||
loginText, aUsername, aPassword,
|
||||
nsnull, PR_FALSE, &btnResult);
|
||||
}
|
||||
else
|
||||
{
|
||||
//nsString loginString;
|
||||
nsXPIDLString loginText;
|
||||
const PRUnichar *userNameStrings[] = { *aUsername };
|
||||
|
||||
NS_NAMED_LITERAL_STRING(loginTextPropertyTag, "loginText");
|
||||
const PRUnichar *dpropertyTag = loginTextPropertyTag.get();
|
||||
rv = bundle->FormatStringFromName(dpropertyTag, userNameStrings, 1,
|
||||
getter_Copies(loginText));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
rv = dlgService->PromptPassword(nsnull, loginTitle, loginText,
|
||||
aPassword, nsnull, PR_FALSE, &btnResult);
|
||||
}
|
||||
}
|
||||
|
||||
return btnResult;
|
||||
}
|
||||
|
||||
PRBool nsMapiHook::VerifyUserName(const PRUnichar *aUsername, char **aIdKey)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
if (aUsername == nsnull)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIMsgAccountManager> accountManager(do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
nsCOMPtr<nsISupportsArray> identities;
|
||||
rv = accountManager->GetAllIdentities(getter_AddRefs(identities));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
PRUint32 numIndentities;
|
||||
identities->Count(&numIndentities);
|
||||
|
||||
for (PRUint32 i = 0; i < numIndentities; i++)
|
||||
{
|
||||
// convert supports->Identity
|
||||
nsCOMPtr<nsISupports> thisSupports;
|
||||
rv = identities->GetElementAt(i, getter_AddRefs(thisSupports));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
nsCOMPtr<nsIMsgIdentity> thisIdentity(do_QueryInterface(thisSupports, &rv));
|
||||
if (NS_SUCCEEDED(rv) && thisIdentity)
|
||||
{
|
||||
nsXPIDLCString email;
|
||||
rv = thisIdentity->GetEmail(getter_Copies(email));
|
||||
if (NS_FAILED(rv)) continue;
|
||||
|
||||
// get the username from the email and compare with the username
|
||||
nsCAutoString aEmail(email.get());
|
||||
PRInt32 index = aEmail.FindChar('@');
|
||||
if (index != -1)
|
||||
aEmail.Truncate(index);
|
||||
|
||||
if (nsDependentString(aUsername) == NS_ConvertASCIItoUCS2(aEmail)) // == overloaded
|
||||
return NS_SUCCEEDED(thisIdentity->GetKey(aIdKey));
|
||||
}
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool
|
||||
nsMapiHook::IsBlindSendAllowed()
|
||||
{
|
||||
PRBool enabled = PR_FALSE;
|
||||
PRBool warn = PR_TRUE;
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefs) {
|
||||
prefs->GetBoolPref(PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND,&warn);
|
||||
prefs->GetBoolPref(PREF_MAPI_BLIND_SEND_ENABLED,&enabled);
|
||||
}
|
||||
if (!enabled)
|
||||
return PR_FALSE;
|
||||
|
||||
if (!warn)
|
||||
return PR_TRUE; // Everything is okay.
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(NS_STRINGBUNDLE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || !bundleService) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = bundleService->CreateBundle(MAPI_PROPERTIES_CHROME, getter_AddRefs(bundle));
|
||||
if (NS_FAILED(rv) || !bundle) return PR_FALSE;
|
||||
|
||||
nsXPIDLString warningMsg;
|
||||
rv = bundle->GetStringFromName(NS_LITERAL_STRING("mapiBlindSendWarning").get(),
|
||||
getter_Copies(warningMsg));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsXPIDLString dontShowAgainMessage;
|
||||
rv = bundle->GetStringFromName(NS_LITERAL_STRING("mapiBlindSendDontShowAgain").get(),
|
||||
getter_Copies(dontShowAgainMessage));
|
||||
if (NS_FAILED(rv)) return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsIPromptService> dlgService(do_GetService("@mozilla.org/embedcomp/prompt-service;1", &rv));
|
||||
if (NS_FAILED(rv) || !dlgService) return PR_FALSE;
|
||||
|
||||
PRBool continueToWarn = PR_TRUE;
|
||||
PRBool okayToContinue = PR_FALSE;
|
||||
dlgService->ConfirmCheck(nsnull, nsnull, warningMsg, dontShowAgainMessage, &continueToWarn, &okayToContinue);
|
||||
|
||||
if (!continueToWarn && okayToContinue && prefs)
|
||||
prefs->SetBoolPref(PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND,PR_FALSE);
|
||||
|
||||
return okayToContinue;
|
||||
|
||||
}
|
||||
|
||||
// this is used for Send without UI
|
||||
nsresult nsMapiHook::BlindSendMail (unsigned long aSession, nsIMsgCompFields * aCompFields)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (!IsBlindSendAllowed())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
/** create nsIMsgComposeParams obj and other fields to populate it **/
|
||||
|
||||
// get parent window
|
||||
nsCOMPtr<nsIAppShellService> appService = do_GetService( "@mozilla.org/appshell/appShellService;1", &rv);
|
||||
if (NS_FAILED(rv)|| (!appService) ) return rv ;
|
||||
|
||||
nsCOMPtr<nsIDOMWindowInternal> hiddenWindow;
|
||||
rv = appService->GetHiddenDOMWindow(getter_AddRefs(hiddenWindow));
|
||||
|
||||
if ( NS_FAILED(rv) ) return rv ;
|
||||
|
||||
// smtp password and Logged in used IdKey from MapiConfig (session obj)
|
||||
nsMAPIConfiguration * pMapiConfig = nsMAPIConfiguration::GetMAPIConfiguration() ;
|
||||
if (!pMapiConfig) return NS_ERROR_FAILURE ; // get the singelton obj
|
||||
PRUnichar * password = pMapiConfig->GetPassword(aSession) ;
|
||||
// password
|
||||
nsCAutoString smtpPassword ;
|
||||
smtpPassword.AssignWithConversion (password) ;
|
||||
// Id key
|
||||
char * MsgIdKey = pMapiConfig->GetIdKey(aSession) ;
|
||||
|
||||
// get the MsgIdentity for the above key using AccountManager
|
||||
nsCOMPtr <nsIMsgAccountManager> accountManager = do_GetService (NS_MSGACCOUNTMANAGER_CONTRACTID) ;
|
||||
if (NS_FAILED(rv) || (!accountManager) ) return rv ;
|
||||
|
||||
nsCOMPtr <nsIMsgIdentity> pMsgId ;
|
||||
rv = accountManager->GetIdentity (MsgIdKey, getter_AddRefs(pMsgId)) ;
|
||||
if (NS_FAILED(rv) ) return rv ;
|
||||
|
||||
// create a send listener to get back the send status
|
||||
nsCOMPtr <nsIMsgSendListener> sendListener ;
|
||||
rv = nsMAPISendListener::CreateMAPISendListener(getter_AddRefs(sendListener)) ;
|
||||
if (NS_FAILED(rv) || (!sendListener) ) return rv;
|
||||
|
||||
// create the compose params object
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || (!pMsgComposeParams) ) return rv ;
|
||||
|
||||
// populate the compose params
|
||||
pMsgComposeParams->SetType(nsIMsgCompType::New);
|
||||
pMsgComposeParams->SetFormat(nsIMsgCompFormat::Default);
|
||||
pMsgComposeParams->SetIdentity(pMsgId);
|
||||
pMsgComposeParams->SetComposeFields(aCompFields);
|
||||
pMsgComposeParams->SetSendListener(sendListener) ;
|
||||
pMsgComposeParams->SetSmtpPassword(smtpPassword.get());
|
||||
|
||||
// create the nsIMsgCompose object to send the object
|
||||
nsCOMPtr<nsIMsgCompose> pMsgCompose (do_CreateInstance(NS_MSGCOMPOSE_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || (!pMsgCompose) ) return rv ;
|
||||
|
||||
/** initialize nsIMsgCompose, Send the message, wait for send completion response **/
|
||||
|
||||
rv = pMsgCompose->Initialize(hiddenWindow, pMsgComposeParams) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
pMsgCompose->SendMsg(nsIMsgSend::nsMsgDeliverNow, pMsgId, nsnull) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
// assign to interface pointer from nsCOMPtr to facilitate typecast below
|
||||
nsIMsgSendListener * pSendListener = sendListener ;
|
||||
|
||||
// we need to wait here to make sure that we return only after send is completed
|
||||
// so we will have a event loop here which will process the events till the Send IsDone.
|
||||
nsCOMPtr<nsIEventQueueService> pEventQService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID, &rv);
|
||||
nsCOMPtr<nsIEventQueue> eventQueue;
|
||||
pEventQService->GetThreadEventQueue(NS_CURRENT_THREAD,getter_AddRefs(eventQueue));
|
||||
while ( !((nsMAPISendListener *) pSendListener)->IsDone() )
|
||||
eventQueue->ProcessPendingEvents();
|
||||
|
||||
return rv ;
|
||||
}
|
||||
|
||||
// this is used to populate comp fields with Unicode data
|
||||
nsresult nsMapiHook::PopulateCompFields(lpnsMapiMessage aMessage,
|
||||
nsIMsgCompFields * aCompFields)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (aMessage->lpOriginator)
|
||||
{
|
||||
PRUnichar * From = aMessage->lpOriginator->lpszAddress ;
|
||||
aCompFields->SetFrom (From) ;
|
||||
}
|
||||
|
||||
nsAutoString To ;
|
||||
nsAutoString Cc ;
|
||||
nsAutoString Bcc ;
|
||||
|
||||
nsAutoString Comma ;
|
||||
Comma.AssignWithConversion(",");
|
||||
|
||||
if (aMessage->lpRecips)
|
||||
{
|
||||
for (int i=0 ; i < (int) aMessage->nRecipCount ; i++)
|
||||
{
|
||||
if (aMessage->lpRecips[i].lpszAddress)
|
||||
{
|
||||
switch (aMessage->lpRecips[i].ulRecipClass)
|
||||
{
|
||||
case MAPI_TO :
|
||||
if (To.Length() > 0)
|
||||
To += Comma ;
|
||||
To += (PRUnichar *) aMessage->lpRecips[i].lpszAddress ;
|
||||
break ;
|
||||
|
||||
case MAPI_CC :
|
||||
if (Cc.Length() > 0)
|
||||
Cc += Comma ;
|
||||
Cc += (PRUnichar *) aMessage->lpRecips[i].lpszAddress ;
|
||||
break ;
|
||||
|
||||
case MAPI_BCC :
|
||||
if (Bcc.Length() > 0)
|
||||
Bcc += Comma ;
|
||||
Bcc += (PRUnichar *) aMessage->lpRecips[i].lpszAddress ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set To, Cc, Bcc
|
||||
aCompFields->SetTo (To.get()) ;
|
||||
aCompFields->SetCc (Cc.get()) ;
|
||||
aCompFields->SetBcc (Bcc.get()) ;
|
||||
|
||||
// set subject
|
||||
if (aMessage->lpszSubject)
|
||||
{
|
||||
PRUnichar * Subject = aMessage->lpszSubject ;
|
||||
aCompFields->SetSubject(Subject) ;
|
||||
}
|
||||
|
||||
// handle attachments as File URL
|
||||
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, PR_TRUE) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
// set body
|
||||
if (aMessage->lpszNoteText)
|
||||
{
|
||||
PRUnichar * Body = aMessage->lpszNoteText ;
|
||||
rv = aCompFields->SetBody(Body) ;
|
||||
}
|
||||
|
||||
#ifdef RAJIV_DEBUG
|
||||
// testing what all was set in CompFields
|
||||
printf ("To : %S \n", To.get()) ;
|
||||
printf ("CC : %S \n", Cc.get() ) ;
|
||||
printf ("BCC : %S \n", Bcc.get() ) ;
|
||||
#endif
|
||||
|
||||
return rv ;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMapiHook::HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32 aFileCount,
|
||||
lpnsMapiFileDesc aFiles, BOOL aIsUnicode)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
nsCAutoString Attachments ;
|
||||
nsCAutoString TempFiles ;
|
||||
|
||||
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pFile) ) return rv ;
|
||||
|
||||
for (int i=0 ; i < aFileCount ; i++)
|
||||
{
|
||||
if (aFiles[i].lpszPathName)
|
||||
{
|
||||
// check if attachment exists
|
||||
if (aIsUnicode)
|
||||
pFile->InitWithUnicodePath (aFiles[i].lpszPathName) ;
|
||||
else
|
||||
pFile->InitWithPath ((char *) aFiles[i].lpszPathName) ;
|
||||
PRBool bExist ;
|
||||
rv = pFile->Exists(&bExist) ;
|
||||
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
|
||||
|
||||
// create Msg attachment object
|
||||
nsCOMPtr<nsIMsgAttachment> attachment = do_CreateInstance(NS_MSGATTACHMENT_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || (!attachment) ) return rv ;
|
||||
|
||||
// set url
|
||||
nsXPIDLCString pURL ;
|
||||
NS_GetURLSpecFromFile(pFile, getter_Copies(pURL));
|
||||
attachment->SetUrl(pURL) ;
|
||||
|
||||
if (aFiles[i].lpszFileName)
|
||||
{
|
||||
if (! aIsUnicode)
|
||||
{
|
||||
nsAutoString realFileName ;
|
||||
realFileName.AssignWithConversion ((char *) aFiles[i].lpszFileName) ;
|
||||
attachment->SetName(realFileName.get()) ;
|
||||
// attachment->SetName( (nsDependentString(aFiles[i].lpszFileName)).get() );
|
||||
}
|
||||
else
|
||||
attachment->SetName(aFiles[i].lpszFileName) ;
|
||||
}
|
||||
|
||||
attachment->SetTemporary(PR_FALSE) ;
|
||||
|
||||
rv = aCompFields->AddAttachment (attachment);
|
||||
}
|
||||
}
|
||||
return rv ;
|
||||
}
|
||||
|
||||
|
||||
// this is used to convert non Unicode data and then populate comp fields
|
||||
nsresult nsMapiHook::PopulateCompFieldsWithConversion(lpnsMapiMessage aMessage,
|
||||
nsIMsgCompFields * aCompFields)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (aMessage->lpOriginator)
|
||||
{
|
||||
nsAutoString From ;
|
||||
From.AssignWithConversion((char *) aMessage->lpOriginator->lpszAddress);
|
||||
aCompFields->SetFrom (From.get()) ;
|
||||
}
|
||||
|
||||
nsAutoString To ;
|
||||
nsAutoString Cc ;
|
||||
nsAutoString Bcc ;
|
||||
|
||||
nsAutoString Comma ;
|
||||
Comma.AssignWithConversion(",");
|
||||
|
||||
if (aMessage->lpRecips)
|
||||
{
|
||||
for (int i=0 ; i < (int) aMessage->nRecipCount ; i++)
|
||||
{
|
||||
if (aMessage->lpRecips[i].lpszAddress)
|
||||
{
|
||||
switch (aMessage->lpRecips[i].ulRecipClass)
|
||||
{
|
||||
case MAPI_TO :
|
||||
if (To.Length() > 0)
|
||||
To += Comma ;
|
||||
To.AppendWithConversion ((char *) aMessage->lpRecips[i].lpszAddress);
|
||||
break ;
|
||||
|
||||
case MAPI_CC :
|
||||
if (Cc.Length() > 0)
|
||||
Cc += Comma ;
|
||||
Cc.AppendWithConversion ((char *) aMessage->lpRecips[i].lpszAddress);
|
||||
break ;
|
||||
|
||||
case MAPI_BCC :
|
||||
if (Bcc.Length() > 0)
|
||||
Bcc += Comma ;
|
||||
Bcc.AppendWithConversion ((char *) aMessage->lpRecips[i].lpszAddress) ;
|
||||
break ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set To, Cc, Bcc
|
||||
aCompFields->SetTo (To.get()) ;
|
||||
aCompFields->SetCc (Cc.get()) ;
|
||||
aCompFields->SetBcc (Bcc.get()) ;
|
||||
|
||||
nsCAutoString platformCharSet;
|
||||
// set subject
|
||||
if (aMessage->lpszSubject)
|
||||
{
|
||||
nsAutoString Subject ;
|
||||
if (platformCharSet.IsEmpty())
|
||||
platformCharSet.Assign(nsMsgI18NFileSystemCharset());
|
||||
rv = ConvertToUnicode(platformCharSet.get(), (char *) aMessage->lpszSubject, Subject);
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
aCompFields->SetSubject(Subject.get()) ;
|
||||
}
|
||||
|
||||
// handle attachments as File URL
|
||||
rv = HandleAttachments (aCompFields, aMessage->nFileCount, aMessage->lpFiles, PR_FALSE) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
// set body
|
||||
if (aMessage->lpszNoteText)
|
||||
{
|
||||
nsAutoString Body ;
|
||||
if (platformCharSet.IsEmpty())
|
||||
platformCharSet.Assign(nsMsgI18NFileSystemCharset());
|
||||
rv = ConvertToUnicode(platformCharSet.get(), (char *) aMessage->lpszNoteText, Body);
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
rv = aCompFields->SetBody(Body.get()) ;
|
||||
}
|
||||
|
||||
#ifdef RAJIV_DEBUG
|
||||
// testing what all was set in CompFields
|
||||
printf ("To : %S \n", To.get()) ;
|
||||
printf ("CC : %S \n", Cc.get() ) ;
|
||||
printf ("BCC : %S \n", Bcc.get() ) ;
|
||||
#endif
|
||||
|
||||
return rv ;
|
||||
}
|
||||
|
||||
// this is used to populate the docs as attachments in the Comp fields for Send Documents
|
||||
nsresult nsMapiHook::PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompFields, ULONG aFlags,
|
||||
PRUnichar * aDelimChar, PRUnichar * aFilePaths)
|
||||
{
|
||||
nsAutoString strDelimChars ;
|
||||
nsString strFilePaths;
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (aFlags & MAPI_UNICODE)
|
||||
{
|
||||
if (aDelimChar)
|
||||
strDelimChars.Assign (aDelimChar) ;
|
||||
if (aFilePaths)
|
||||
strFilePaths.Assign (aFilePaths) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (aDelimChar)
|
||||
strDelimChars.AssignWithConversion ((char*) aDelimChar) ;
|
||||
if (aFilePaths)
|
||||
strFilePaths.AssignWithConversion ((char *) aFilePaths) ;
|
||||
}
|
||||
|
||||
// check for comma in filename
|
||||
if (strDelimChars.Find (",") == kNotFound) // if comma is not in the delimiter specified by user
|
||||
{
|
||||
if (strFilePaths.Find(",") != kNotFound) // if comma found in filenames return error
|
||||
return NS_ERROR_FILE_INVALID_PATH ;
|
||||
}
|
||||
|
||||
nsCString Attachments ;
|
||||
|
||||
// only 1 file is to be sent, no delim specified
|
||||
if ((!strDelimChars.Length()) && (strFilePaths.Length()>0))
|
||||
{
|
||||
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pFile) ) return rv ;
|
||||
pFile->InitWithUnicodePath (strFilePaths.get()) ;
|
||||
|
||||
PRBool bExist ;
|
||||
rv = pFile->Exists(&bExist) ;
|
||||
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
|
||||
|
||||
nsXPIDLCString pURL ;
|
||||
NS_GetURLSpecFromFile(pFile, getter_Copies(pURL));
|
||||
if (pURL)
|
||||
Attachments.Assign(pURL) ;
|
||||
|
||||
// set attachments for comp field and return
|
||||
rv = aCompFields->SetAttachments (Attachments.get());
|
||||
return rv ;
|
||||
}
|
||||
|
||||
// multiple files to be sent, delim specified
|
||||
nsCOMPtr <nsILocalFile> pFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pFile) ) return rv ;
|
||||
PRInt32 offset = 0 ;
|
||||
PRInt32 FilePathsLen = strFilePaths.Length() ;
|
||||
if (FilePathsLen)
|
||||
{
|
||||
PRUnichar * newFilePaths = (PRUnichar *) strFilePaths.get() ;
|
||||
while (offset != kNotFound)
|
||||
{
|
||||
nsString RemainingPaths ;
|
||||
RemainingPaths.Assign(newFilePaths) ;
|
||||
offset = RemainingPaths.Find (strDelimChars) ;
|
||||
if (offset != kNotFound)
|
||||
{
|
||||
RemainingPaths.SetLength (offset) ;
|
||||
if ((offset + strDelimChars.Length()) < FilePathsLen)
|
||||
newFilePaths += offset + strDelimChars.Length() ;
|
||||
}
|
||||
|
||||
pFile->InitWithUnicodePath (RemainingPaths.get()) ;
|
||||
|
||||
#ifdef RAJIV_DEBUG
|
||||
printf ("File : %S \n", RemainingPaths.get()) ;
|
||||
#endif
|
||||
PRBool bExist ;
|
||||
rv = pFile->Exists(&bExist) ;
|
||||
if (NS_FAILED(rv) || (!bExist) ) return NS_ERROR_FILE_TARGET_DOES_NOT_EXIST ;
|
||||
|
||||
nsXPIDLCString pURL ;
|
||||
NS_GetURLSpecFromFile(pFile, getter_Copies(pURL));
|
||||
if (pURL)
|
||||
{
|
||||
if (Attachments.Length() > 0)
|
||||
Attachments.Append(",") ;
|
||||
Attachments.Append(pURL) ;
|
||||
}
|
||||
}
|
||||
rv = aCompFields->SetAttachments (Attachments.get());
|
||||
}
|
||||
|
||||
return rv ;
|
||||
}
|
||||
|
||||
// this used for Send with UI
|
||||
nsresult nsMapiHook::ShowComposerWindow (unsigned long aSession, nsIMsgCompFields * aCompFields)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
// create a send listener to get back the send status
|
||||
nsCOMPtr <nsIMsgSendListener> sendListener ;
|
||||
rv = nsMAPISendListener::CreateMAPISendListener(getter_AddRefs(sendListener)) ;
|
||||
if (NS_FAILED(rv) || (!sendListener) ) return rv ;
|
||||
|
||||
// create the compose params object
|
||||
nsCOMPtr<nsIMsgComposeParams> pMsgComposeParams (do_CreateInstance(NS_MSGCOMPOSEPARAMS_CONTRACTID, &rv));
|
||||
if (NS_FAILED(rv) || (!pMsgComposeParams) ) return rv ;
|
||||
|
||||
// populate the compose params
|
||||
pMsgComposeParams->SetType(nsIMsgCompType::New);
|
||||
pMsgComposeParams->SetFormat(nsIMsgCompFormat::Default);
|
||||
pMsgComposeParams->SetComposeFields(aCompFields);
|
||||
pMsgComposeParams->SetSendListener(sendListener) ;
|
||||
|
||||
/** get the nsIMsgComposeService object to open the compose window **/
|
||||
nsCOMPtr <nsIMsgComposeService> compService = do_GetService (NS_MSGCOMPOSESERVICE_CONTRACTID) ;
|
||||
if (NS_FAILED(rv)|| (!compService) ) return rv ;
|
||||
|
||||
rv = compService->OpenComposeWindowWithParams(nsnull, pMsgComposeParams) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
return rv ;
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MSG_MAPI_HOOK_H_
|
||||
#define MSG_MAPI_HOOK_H_
|
||||
|
||||
#include "prtypes.h"
|
||||
|
||||
class nsMapiHook
|
||||
{
|
||||
public :
|
||||
|
||||
static PRBool Initialize();
|
||||
static PRBool DisplayLoginDialog(PRBool aLogin, PRUnichar **aUsername,
|
||||
PRUnichar **aPassword);
|
||||
static PRBool VerifyUserName(const PRUnichar *aUsername, char **aIdKey);
|
||||
|
||||
static PRBool IsBlindSendAllowed () ;
|
||||
static nsresult BlindSendMail (unsigned long aSession, nsIMsgCompFields * aCompFields) ;
|
||||
static nsresult ShowComposerWindow (unsigned long aSession, nsIMsgCompFields * aCompFields) ;
|
||||
static nsresult PopulateCompFields(lpnsMapiMessage aMessage, nsIMsgCompFields * aCompFields) ;
|
||||
static nsresult PopulateCompFieldsWithConversion(lpnsMapiMessage aMessage,
|
||||
nsIMsgCompFields * aCompFields) ;
|
||||
static nsresult PopulateCompFieldsForSendDocs(nsIMsgCompFields * aCompFields,
|
||||
ULONG aFlags, LPTSTR aDelimChar, LPTSTR aFilePaths) ;
|
||||
static nsresult HandleAttachments (nsIMsgCompFields * aCompFields, PRInt32 aFileCount,
|
||||
lpnsMapiFileDesc aFiles, BOOL aIsUnicode) ;
|
||||
static void CleanUp();
|
||||
|
||||
static PRBool isMapiService;
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_HOOK_H_
|
||||
@@ -1,266 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
* Contributor(s): Rajiv Dayal (rdayal@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <mapidefs.h>
|
||||
#include <mapi.h>
|
||||
#include "msgMapi.h"
|
||||
#include "msgMapiImp.h"
|
||||
#include "msgMapiFactory.h"
|
||||
#include "msgMapiMain.h"
|
||||
|
||||
#include "nsMsgCompFields.h"
|
||||
#include "msgMapiHook.h"
|
||||
#include "nsString.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nsMsgCompCID.h"
|
||||
|
||||
|
||||
|
||||
CMapiImp::CMapiImp()
|
||||
: m_cRef(1)
|
||||
{
|
||||
m_Lock = PR_NewLock();
|
||||
}
|
||||
|
||||
CMapiImp::~CMapiImp()
|
||||
{
|
||||
if (m_Lock)
|
||||
PR_DestroyLock(m_Lock);
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::QueryInterface(const IID& aIid, void** aPpv)
|
||||
{
|
||||
if (aIid == IID_IUnknown)
|
||||
{
|
||||
*aPpv = static_cast<nsIMapi*>(this);
|
||||
}
|
||||
else if (aIid == IID_nsIMapi)
|
||||
{
|
||||
*aPpv = static_cast<nsIMapi*>(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
*aPpv = nsnull;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
reinterpret_cast<IUnknown*>(*aPpv)->AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CMapiImp::AddRef()
|
||||
{
|
||||
return PR_AtomicIncrement(&m_cRef);
|
||||
}
|
||||
|
||||
STDMETHODIMP_(ULONG) CMapiImp::Release()
|
||||
{
|
||||
PRInt32 temp;
|
||||
temp = PR_AtomicDecrement(&m_cRef);
|
||||
if (m_cRef == 0)
|
||||
{
|
||||
delete this;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::IsValid()
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::IsValidSession(unsigned long aSession)
|
||||
{
|
||||
nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
|
||||
if (pConfig && pConfig->IsSessionValid(aSession))
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::Initialize()
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
|
||||
if (!m_Lock)
|
||||
return E_FAIL;
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
// Initialize MAPI Configuration
|
||||
|
||||
nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
|
||||
if (pConfig != nsnull)
|
||||
if (nsMapiHook::Initialize())
|
||||
hr = S_OK;
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::Login(unsigned long aUIArg, LOGIN_PW_TYPE aLogin, LOGIN_PW_TYPE aPassWord,
|
||||
unsigned long aFlags, unsigned long *aSessionId)
|
||||
{
|
||||
HRESULT hr = E_FAIL;
|
||||
PRBool bNewSession = PR_FALSE;
|
||||
char *id_key = nsnull;
|
||||
|
||||
if (aFlags & MAPI_NEW_SESSION)
|
||||
bNewSession = PR_TRUE;
|
||||
|
||||
// Check For Profile Name
|
||||
|
||||
if (aLogin != nsnull && aLogin[0] != '\0')
|
||||
{
|
||||
if (nsMapiHook::VerifyUserName(aLogin, &id_key) == PR_FALSE)
|
||||
{
|
||||
*aSessionId = MAPI_E_LOGIN_FAILURE;
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
// finally register(create) the session.
|
||||
|
||||
PRUint32 nSession_Id;
|
||||
PRInt16 nResult = 0;
|
||||
|
||||
nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
|
||||
if (pConfig != nsnull)
|
||||
nResult = pConfig->RegisterSession(aUIArg, aLogin, aPassWord,
|
||||
(aFlags & MAPI_FORCE_DOWNLOAD), bNewSession,
|
||||
&nSession_Id, id_key);
|
||||
|
||||
switch (nResult)
|
||||
{
|
||||
case -1 :
|
||||
{
|
||||
*aSessionId = MAPI_E_TOO_MANY_SESSIONS;
|
||||
return hr;
|
||||
}
|
||||
case 0 :
|
||||
{
|
||||
*aSessionId = MAPI_E_INSUFFICIENT_MEMORY;
|
||||
return hr;
|
||||
}
|
||||
default :
|
||||
{
|
||||
*aSessionId = nSession_Id;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::SendMail( unsigned long aSession, lpnsMapiMessage aMessage,
|
||||
short aRecipCount, lpnsMapiRecipDesc aRecips , short aFileCount, lpnsMapiFileDesc aFiles ,
|
||||
unsigned long aFlags, unsigned long aReserved)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
// Assign the pointers in the aMessage struct to the array of Recips and Files
|
||||
// recieved here from MS COM. These are used in BlindSendMail and ShowCompWin fns
|
||||
aMessage->lpRecips = aRecips ;
|
||||
aMessage->lpFiles = aFiles ;
|
||||
|
||||
/** create nsIMsgCompFields obj and populate it **/
|
||||
nsCOMPtr<nsIMsgCompFields> pCompFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pCompFields) ) return MAPI_E_INSUFFICIENT_MEMORY ;
|
||||
|
||||
if (aFlags & MAPI_UNICODE)
|
||||
rv = nsMapiHook::PopulateCompFields(aMessage, pCompFields) ;
|
||||
else
|
||||
rv = nsMapiHook::PopulateCompFieldsWithConversion(aMessage, pCompFields) ;
|
||||
|
||||
if (NS_SUCCEEDED (rv))
|
||||
{
|
||||
// see flag to see if UI needs to be brought up
|
||||
if (!(aFlags & MAPI_DIALOG))
|
||||
{
|
||||
rv = nsMapiHook::BlindSendMail(aSession, pCompFields);
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = nsMapiHook::ShowComposerWindow(aSession, pCompFields);
|
||||
}
|
||||
}
|
||||
|
||||
return nsMAPIConfiguration::GetMAPIErrorFromNSError (rv) ;
|
||||
}
|
||||
|
||||
|
||||
STDMETHODIMP CMapiImp::SendDocuments( unsigned long aSession, LPTSTR aDelimChar,
|
||||
LPTSTR aFilePaths, LPTSTR aFileNames, ULONG aFlags)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
/** create nsIMsgCompFields obj and populate it **/
|
||||
nsCOMPtr<nsIMsgCompFields> pCompFields = do_CreateInstance(NS_MSGCOMPFIELDS_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv) || (!pCompFields) ) return MAPI_E_INSUFFICIENT_MEMORY ;
|
||||
|
||||
if (aFilePaths)
|
||||
{
|
||||
rv = nsMapiHook::PopulateCompFieldsForSendDocs(pCompFields, aFlags, aDelimChar, aFilePaths) ;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED (rv))
|
||||
rv = nsMapiHook::ShowComposerWindow(aSession, pCompFields);
|
||||
|
||||
return nsMAPIConfiguration::GetMAPIErrorFromNSError (rv) ;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::Logoff (unsigned long aSession)
|
||||
{
|
||||
nsMAPIConfiguration *pConfig = nsMAPIConfiguration::GetMAPIConfiguration();
|
||||
|
||||
if (pConfig->UnRegisterSession((PRUint32)aSession))
|
||||
return S_OK;
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
STDMETHODIMP CMapiImp::CleanUp()
|
||||
{
|
||||
nsMapiHook::CleanUp();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,92 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MSG_MAPI_IMP_H
|
||||
#define MSG_MAPI_IMP_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <mapi.h>
|
||||
#include "msgMapi.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nspr.h"
|
||||
|
||||
const CLSID CLSID_CMapiImp = {0x29f458be, 0x8866, 0x11d5, {0xa3, 0xdd, 0x0, 0xb0, 0xd0, 0xf3, 0xba, 0xa7}};
|
||||
|
||||
// this class implements the MS COM interface nsIMapi that provides the methods
|
||||
// called by mapi32.dll to perform the mail operations as specified by MAPI.
|
||||
// These class methods in turn use the Mozilla Mail XPCOM interfaces to do so.
|
||||
class CMapiImp : public nsIMapi
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
// IUnknown
|
||||
|
||||
STDMETHODIMP QueryInterface(const IID& aIid, void** aPpv);
|
||||
STDMETHODIMP_(ULONG) AddRef();
|
||||
STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
// Interface INsMapi
|
||||
|
||||
STDMETHODIMP Login(unsigned long aUIArg, LOGIN_PW_TYPE aLogin,
|
||||
LOGIN_PW_TYPE aPassWord, unsigned long aFlags,
|
||||
unsigned long *aSessionId);
|
||||
|
||||
STDMETHODIMP SendMail( unsigned long aSession, lpnsMapiMessage aMessage,
|
||||
short aRecipCount, lpnsMapiRecipDesc aRecips ,
|
||||
short aFileCount, lpnsMapiFileDesc aFiles ,
|
||||
unsigned long aFlags, unsigned long aReserved) ;
|
||||
|
||||
STDMETHODIMP SendDocuments( unsigned long aSession, LPTSTR aDelimChar,
|
||||
LPTSTR aFilePaths, LPTSTR aFileNames, ULONG aFlags);
|
||||
|
||||
STDMETHODIMP Initialize();
|
||||
STDMETHODIMP IsValid();
|
||||
STDMETHODIMP IsValidSession(unsigned long aSession);
|
||||
|
||||
STDMETHODIMP Logoff (unsigned long aSession);
|
||||
STDMETHODIMP CleanUp();
|
||||
|
||||
CMapiImp();
|
||||
~CMapiImp();
|
||||
|
||||
private :
|
||||
|
||||
PRLock *m_Lock;
|
||||
PRInt32 m_cRef;
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_IMP_H
|
||||
@@ -1,376 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include <mapidefs.h>
|
||||
#include <mapi.h>
|
||||
|
||||
#include "msgCore.h"
|
||||
#include "nsMsgComposeStringBundle.h"
|
||||
#include "msgMapiMain.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// move to xpcom bug 81956.
|
||||
class nsPRUintKey : public nsHashKey {
|
||||
protected:
|
||||
PRUint32 mKey;
|
||||
public:
|
||||
nsPRUintKey(PRUint32 key) : mKey(key) {}
|
||||
|
||||
PRUint32 HashCode(void) const {
|
||||
return mKey;
|
||||
}
|
||||
|
||||
PRBool Equals(const nsHashKey *aKey) const {
|
||||
return mKey == ((const nsPRUintKey *) aKey)->mKey;
|
||||
}
|
||||
nsHashKey *Clone() const {
|
||||
return new nsPRUintKey(mKey);
|
||||
}
|
||||
PRUint32 GetValue() { return mKey; }
|
||||
};
|
||||
//
|
||||
|
||||
|
||||
nsMAPIConfiguration *nsMAPIConfiguration::m_pSelfRef = nsnull;
|
||||
PRUint32 nsMAPIConfiguration::session_generator = 0;
|
||||
PRUint32 nsMAPIConfiguration::sessionCount = 0;
|
||||
|
||||
nsMAPIConfiguration *nsMAPIConfiguration::GetMAPIConfiguration()
|
||||
{
|
||||
if (m_pSelfRef == nsnull)
|
||||
m_pSelfRef = new nsMAPIConfiguration();
|
||||
|
||||
return m_pSelfRef;
|
||||
}
|
||||
|
||||
nsMAPIConfiguration::nsMAPIConfiguration()
|
||||
: m_nMaxSessions(MAX_SESSIONS)
|
||||
{
|
||||
m_Lock = PR_NewLock();
|
||||
}
|
||||
|
||||
static PRBool
|
||||
FreeSessionMapEntries(nsHashKey *aKey, void *aData, void* aClosure)
|
||||
{
|
||||
nsMAPISession *pTemp = (nsMAPISession*) aData;
|
||||
if (pTemp)
|
||||
{
|
||||
delete pTemp;
|
||||
pTemp = nsnull;
|
||||
}
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
static PRBool
|
||||
FreeProfileMapEntries(nsHashKey *aKey, void *aData, void* aClosure)
|
||||
{
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
nsMAPIConfiguration::~nsMAPIConfiguration()
|
||||
{
|
||||
if (m_Lock)
|
||||
PR_DestroyLock(m_Lock);
|
||||
|
||||
m_SessionMap.Reset(FreeSessionMapEntries);
|
||||
m_ProfileMap.Reset(FreeProfileMapEntries);
|
||||
}
|
||||
|
||||
void nsMAPIConfiguration::OpenConfiguration()
|
||||
{
|
||||
// No. of max. sessions is set to MAX_SESSIONS. In future
|
||||
// if it is decided to have configuration (registry)
|
||||
// parameter, this function can be used to set the
|
||||
// max sessions;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
PRInt16 nsMAPIConfiguration::RegisterSession(PRUint32 aHwnd,
|
||||
const PRUnichar *aUserName, const PRUnichar *aPassword,
|
||||
PRBool aForceDownLoad, PRBool aNewSession,
|
||||
PRUint32 *aSession, char *aIdKey)
|
||||
{
|
||||
PRInt16 nResult = 0;
|
||||
PRUint32 n_SessionId = 0;
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
// Check whether max sessions is exceeded
|
||||
|
||||
if (sessionCount >= m_nMaxSessions)
|
||||
{
|
||||
PR_Unlock(m_Lock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (aUserName != nsnull && aUserName[0] != '\0')
|
||||
{
|
||||
nsStringKey usernameKey(aUserName);
|
||||
n_SessionId = (PRUint32) m_ProfileMap.Get(&usernameKey);
|
||||
}
|
||||
|
||||
// try to share a session; if not create a session
|
||||
|
||||
if (n_SessionId > 0)
|
||||
{
|
||||
nsPRUintKey sessionKey(n_SessionId);
|
||||
nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
|
||||
if (pTemp != nsnull)
|
||||
{
|
||||
pTemp->IncrementSession();
|
||||
*aSession = n_SessionId;
|
||||
nResult = 1;
|
||||
}
|
||||
}
|
||||
else if (aNewSession || n_SessionId == 0) // checking for n_SessionId is a concession
|
||||
{
|
||||
// create a new session ; if new session is specified OR there is no session
|
||||
nsMAPISession *pTemp = nsnull;
|
||||
pTemp = new nsMAPISession(aHwnd, aUserName,
|
||||
aPassword, aForceDownLoad, aIdKey);
|
||||
|
||||
if (pTemp != nsnull)
|
||||
{
|
||||
session_generator++;
|
||||
|
||||
// I don't think there will be (2 power 32) sessions alive
|
||||
// in a cycle. This is an assumption
|
||||
|
||||
if (session_generator == 0)
|
||||
session_generator++;
|
||||
|
||||
nsPRUintKey sessionKey(session_generator);
|
||||
m_SessionMap.Put(&sessionKey, pTemp);
|
||||
if (aUserName != nsnull && aUserName[0] != '\0')
|
||||
{
|
||||
nsStringKey usernameKey(aUserName);
|
||||
m_ProfileMap.Put(&usernameKey, (void*)session_generator);
|
||||
}
|
||||
|
||||
*aSession = session_generator;
|
||||
sessionCount++;
|
||||
nResult = 1;
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
return nResult;
|
||||
}
|
||||
|
||||
PRBool nsMAPIConfiguration::UnRegisterSession(PRUint32 aSessionID)
|
||||
{
|
||||
PRBool bResult = PR_FALSE;
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
if (aSessionID != 0)
|
||||
{
|
||||
nsPRUintKey sessionKey(aSessionID);
|
||||
nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
|
||||
|
||||
if (pTemp != nsnull)
|
||||
{
|
||||
if (pTemp->DecrementSession() == 0)
|
||||
{
|
||||
if (pTemp->m_pProfileName.get() != nsnull)
|
||||
{
|
||||
nsStringKey stringKey(pTemp->m_pProfileName.get());
|
||||
m_ProfileMap.Remove(&stringKey);
|
||||
}
|
||||
m_SessionMap.Remove(&sessionKey);
|
||||
sessionCount--;
|
||||
bResult = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
return bResult;
|
||||
}
|
||||
|
||||
PRBool nsMAPIConfiguration::IsSessionValid(PRUint32 aSessionID)
|
||||
{
|
||||
if (aSessionID == 0)
|
||||
return PR_FALSE;
|
||||
|
||||
PRBool retValue = PR_FALSE;
|
||||
nsPRUintKey sessionKey(aSessionID);
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
retValue = m_SessionMap.Exists(&sessionKey);
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
|
||||
PRUnichar *nsMAPIConfiguration::GetPassword(PRUint32 aSessionID)
|
||||
{
|
||||
PRUnichar *pResult = nsnull;
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
if (aSessionID != 0)
|
||||
{
|
||||
nsPRUintKey sessionKey(aSessionID);
|
||||
nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
|
||||
|
||||
if (pTemp)
|
||||
{
|
||||
pResult = pTemp->GetPassword();
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
|
||||
return pResult;
|
||||
}
|
||||
|
||||
char *nsMAPIConfiguration::GetIdKey(PRUint32 aSessionID)
|
||||
{
|
||||
char *pResult = nsnull;
|
||||
|
||||
PR_Lock(m_Lock);
|
||||
|
||||
if (aSessionID != 0)
|
||||
{
|
||||
nsPRUintKey sessionKey(aSessionID);
|
||||
nsMAPISession *pTemp = (nsMAPISession *)m_SessionMap.Get(&sessionKey);
|
||||
if (pTemp)
|
||||
{
|
||||
pResult = pTemp->GetIdKey();
|
||||
}
|
||||
}
|
||||
|
||||
PR_Unlock(m_Lock);
|
||||
return pResult;
|
||||
}
|
||||
|
||||
// util func
|
||||
HRESULT nsMAPIConfiguration::GetMAPIErrorFromNSError (nsresult res)
|
||||
{
|
||||
HRESULT hr = SUCCESS_SUCCESS ;
|
||||
|
||||
if (NS_SUCCEEDED (hr)) return hr ;
|
||||
|
||||
// if failure return the related MAPI failure code
|
||||
switch (res)
|
||||
{
|
||||
case NS_MSG_NO_RECIPIENTS :
|
||||
hr = MAPI_E_BAD_RECIPTYPE ;
|
||||
break ;
|
||||
case NS_ERROR_COULD_NOT_GET_USERS_MAIL_ADDRESS :
|
||||
hr = MAPI_E_INVALID_RECIPS ;
|
||||
break ;
|
||||
case NS_ERROR_COULD_NOT_LOGIN_TO_SMTP_SERVER :
|
||||
hr = MAPI_E_LOGIN_FAILURE ;
|
||||
break ;
|
||||
case NS_MSG_UNABLE_TO_OPEN_FILE :
|
||||
case NS_MSG_UNABLE_TO_OPEN_TMP_FILE :
|
||||
case NS_MSG_COULDNT_OPEN_FCC_FOLDER :
|
||||
case NS_ERROR_FILE_INVALID_PATH :
|
||||
hr = MAPI_E_ATTACHMENT_OPEN_FAILURE ;
|
||||
break ;
|
||||
case NS_ERROR_FILE_TARGET_DOES_NOT_EXIST :
|
||||
hr = MAPI_E_ATTACHMENT_NOT_FOUND ;
|
||||
break ;
|
||||
case NS_MSG_CANCELLING :
|
||||
hr = MAPI_E_USER_ABORT ;
|
||||
break ;
|
||||
case NS_MSG_ERROR_WRITING_FILE :
|
||||
case NS_MSG_UNABLE_TO_SAVE_TEMPLATE :
|
||||
case NS_MSG_UNABLE_TO_SAVE_DRAFT :
|
||||
hr = MAPI_E_ATTACHMENT_WRITE_FAILURE ;
|
||||
break ;
|
||||
default :
|
||||
hr = MAPI_E_FAILURE ;
|
||||
break ;
|
||||
}
|
||||
|
||||
return hr ;
|
||||
}
|
||||
|
||||
|
||||
nsMAPISession::nsMAPISession(PRUint32 aHwnd, const PRUnichar *aUserName,\
|
||||
const PRUnichar *aPassword, \
|
||||
PRBool aForceDownLoad, char *aKey)
|
||||
: m_bIsForcedDownLoad(aForceDownLoad),
|
||||
m_hAppHandle(aHwnd),
|
||||
m_nShared(1),
|
||||
m_pIdKey(aKey)
|
||||
{
|
||||
m_pProfileName.Assign(aUserName);
|
||||
m_pPassword.Assign(aPassword);
|
||||
}
|
||||
|
||||
nsMAPISession::~nsMAPISession()
|
||||
{
|
||||
if (m_pIdKey != nsnull)
|
||||
{
|
||||
delete [] m_pIdKey;
|
||||
m_pIdKey = nsnull;
|
||||
}
|
||||
}
|
||||
|
||||
PRUint32 nsMAPISession::IncrementSession()
|
||||
{
|
||||
return ++m_nShared;
|
||||
}
|
||||
|
||||
PRUint32 nsMAPISession::DecrementSession()
|
||||
{
|
||||
return --m_nShared;
|
||||
}
|
||||
|
||||
PRUint32 nsMAPISession::GetSessionCount()
|
||||
{
|
||||
return m_nShared;
|
||||
}
|
||||
|
||||
PRUnichar *nsMAPISession::GetPassword()
|
||||
{
|
||||
return (PRUnichar *)m_pPassword.get();
|
||||
}
|
||||
|
||||
char *nsMAPISession::GetIdKey()
|
||||
{
|
||||
return m_pIdKey;
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MSG_MAPI_MAIN_H_
|
||||
#define NSG_MAPI_MAIN_H_
|
||||
|
||||
#define MAX_NAME_LEN 256
|
||||
#define MAX_PW_LEN 256
|
||||
#define MAX_SESSIONS 50
|
||||
#define MAPI_SENDCOMPLETE_EVENT "SendCompletionEvent"
|
||||
|
||||
#define MAPI_PROPERTIES_CHROME "chrome://messenger-mapi/locale/mapi.properties"
|
||||
#define PREF_MAPI_WARN_PRIOR_TO_BLIND_SEND "mapi.blind-send.warn"
|
||||
#define PREF_MAPI_BLIND_SEND_ENABLED "mapi.blind-send.enabled"
|
||||
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nspr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsHashtable.h"
|
||||
|
||||
class nsMAPIConfiguration
|
||||
{
|
||||
private :
|
||||
|
||||
static PRUint32 session_generator;
|
||||
static PRUint32 sessionCount;
|
||||
static nsMAPIConfiguration *m_pSelfRef;
|
||||
PRLock *m_Lock;
|
||||
PRUint32 m_nMaxSessions;
|
||||
|
||||
|
||||
nsHashtable m_ProfileMap;
|
||||
nsHashtable m_SessionMap;
|
||||
nsMAPIConfiguration();
|
||||
|
||||
public :
|
||||
static nsMAPIConfiguration *GetMAPIConfiguration();
|
||||
void OpenConfiguration();
|
||||
PRInt16 RegisterSession(PRUint32 aHwnd, const PRUnichar *aUserName, \
|
||||
const PRUnichar *aPassword, PRBool aForceDownLoad, \
|
||||
PRBool aNewSession, PRUint32 *aSession, char *aIdKey);
|
||||
PRBool IsSessionValid(PRUint32 aSessionID);
|
||||
PRBool UnRegisterSession(PRUint32 aSessionID);
|
||||
PRUnichar *GetPassword(PRUint32 aSessionID);
|
||||
char *GetIdKey(PRUint32 aSessionID);
|
||||
~nsMAPIConfiguration();
|
||||
|
||||
// a util func
|
||||
static HRESULT GetMAPIErrorFromNSError (nsresult res) ;
|
||||
};
|
||||
|
||||
class nsMAPISession
|
||||
{
|
||||
friend class nsMAPIConfiguration;
|
||||
|
||||
private :
|
||||
|
||||
PRBool m_bIsForcedDownLoad;
|
||||
PRBool m_bApp_or_Service;
|
||||
PRUint32 m_hAppHandle;
|
||||
PRUint32 m_nShared;
|
||||
char *m_pIdKey;
|
||||
nsString m_pProfileName;
|
||||
nsString m_pPassword;
|
||||
|
||||
public :
|
||||
|
||||
nsMAPISession(PRUint32 aHwnd, const PRUnichar *aUserName, \
|
||||
const PRUnichar *aPassword, \
|
||||
PRBool aForceDownLoad, char *aKey);
|
||||
PRUint32 IncrementSession();
|
||||
PRUint32 DecrementSession();
|
||||
PRUint32 GetSessionCount();
|
||||
PRUnichar *nsMAPISession::GetPassword();
|
||||
char *nsMAPISession::GetIdKey();
|
||||
~nsMAPISession();
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_MAIN_H_
|
||||
@@ -1,209 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
#include "nsCOMPtr.h"
|
||||
#include "objbase.h"
|
||||
#include "nsISupports.h"
|
||||
|
||||
#include "nsIGenericFactory.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIAppStartupNotifier.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
|
||||
#include "nsIPrefService.h"
|
||||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranchInternal.h"
|
||||
|
||||
#include "msgMapiSupport.h"
|
||||
#include "nsMapiRegistryUtils.h"
|
||||
#include "nsMapiRegistry.h"
|
||||
#include "msgMapiImp.h"
|
||||
|
||||
/** Implementation of the nsIMapiSupport interface.
|
||||
* Use standard implementation of nsISupports stuff.
|
||||
*/
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS2(nsMapiSupport, nsIMapiSupport, nsIObserver);
|
||||
|
||||
static NS_METHOD nsMapiRegistrationProc(nsIComponentManager *aCompMgr,
|
||||
nsIFile *aPath, const char *registryLocation, const char *componentType,
|
||||
const nsModuleComponentInfo *info)
|
||||
{
|
||||
|
||||
nsresult rv;
|
||||
|
||||
nsCOMPtr<nsICategoryManager> categoryManager(do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv));
|
||||
if (NS_SUCCEEDED(rv))
|
||||
rv = categoryManager->AddCategoryEntry(APPSTARTUP_CATEGORY, "Mapi Support",
|
||||
"service," NS_IMAPISUPPORT_CONTRACTID, PR_TRUE, PR_TRUE, nsnull);
|
||||
|
||||
return rv ;
|
||||
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, "profile-after-change"))
|
||||
return InitializeMAPISupport();
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID))
|
||||
return ShutdownMAPISupport();
|
||||
|
||||
if (!nsCRT::strcmp(aTopic, NS_PREFBRANCH_PREFCHANGE_TOPIC_ID))
|
||||
{
|
||||
nsCOMPtr<nsIPrefBranch> prefs = do_QueryInterface(aSubject, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
// which preference changed?
|
||||
if (!nsCRT::strcmp(MAILNEWS_ALLOW_DEFAULT_MAIL_CLIENT, NS_ConvertUCS2toUTF8(aData).get()))
|
||||
{
|
||||
PRBool bIsDefault = PR_FALSE ;
|
||||
rv = prefs->GetBoolPref(MAILNEWS_ALLOW_DEFAULT_MAIL_CLIENT, &bIsDefault);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr <nsIMapiRegistry> mapiRegistry = do_CreateInstance(NS_IMAPIREGISTRY_CONTRACTID, &rv) ;
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
return mapiRegistry->SetIsDefaultMailClient(bIsDefault) ;
|
||||
}
|
||||
return rv ;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIObserverService> observerService(do_GetService("@mozilla.org/observer-service;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = observerService->AddObserver(this,"profile-after-change", PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = observerService->AddObserver(this, NS_XPCOM_SHUTDOWN_OBSERVER_ID, PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCOMPtr<nsIPrefBranchInternal> prefInternal = do_QueryInterface(prefs, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
rv = prefInternal->AddObserver(MAILNEWS_ALLOW_DEFAULT_MAIL_CLIENT, this, PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
nsMapiSupport::nsMapiSupport()
|
||||
: m_dwRegister(0),
|
||||
m_nsMapiFactory(nsnull)
|
||||
{
|
||||
NS_INIT_ISUPPORTS();
|
||||
}
|
||||
|
||||
nsMapiSupport::~nsMapiSupport()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::InitializeMAPISupport()
|
||||
{
|
||||
::CoInitialize(nsnull) ;
|
||||
|
||||
if (m_nsMapiFactory == nsnull) // No Registering if already done. Sanity Check!!
|
||||
{
|
||||
m_nsMapiFactory = new CMapiFactory();
|
||||
|
||||
if (m_nsMapiFactory != nsnull)
|
||||
{
|
||||
HRESULT hr = ::CoRegisterClassObject(CLSID_CMapiImp, \
|
||||
m_nsMapiFactory, \
|
||||
CLSCTX_LOCAL_SERVER, \
|
||||
REGCLS_MULTIPLEUSE, \
|
||||
&m_dwRegister);
|
||||
|
||||
if (FAILED(hr))
|
||||
{
|
||||
m_nsMapiFactory->Release() ;
|
||||
m_nsMapiFactory = nsnull;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiSupport::ShutdownMAPISupport()
|
||||
{
|
||||
if (m_dwRegister != 0)
|
||||
::CoRevokeClassObject(m_dwRegister);
|
||||
|
||||
if (m_nsMapiFactory != nsnull)
|
||||
{
|
||||
m_nsMapiFactory->Release();
|
||||
m_nsMapiFactory = nsnull;
|
||||
}
|
||||
|
||||
::CoUninitialize();
|
||||
|
||||
return NS_OK ;
|
||||
}
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiRegistry);
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMapiSupport);
|
||||
|
||||
// The list of components we register
|
||||
static nsModuleComponentInfo components[] =
|
||||
{
|
||||
{
|
||||
NS_IMAPIREGISTRY_CLASSNAME,
|
||||
NS_IMAPIREGISTRY_CID,
|
||||
NS_IMAPIREGISTRY_CONTRACTID,
|
||||
nsMapiRegistryConstructor
|
||||
},
|
||||
|
||||
{
|
||||
NS_IMAPISUPPORT_CLASSNAME,
|
||||
NS_IMAPISUPPORT_CID,
|
||||
NS_IMAPISUPPORT_CONTRACTID,
|
||||
nsMapiSupportConstructor,
|
||||
nsMapiRegistrationProc,
|
||||
nsnull
|
||||
}
|
||||
};
|
||||
|
||||
NS_IMPL_NSGETMODULE(msgMapiModule, components);
|
||||
|
||||
@@ -1,66 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Mozilla
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
# Netscape Communications Corp.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s): Krishna Mohan Khandrika (kkhandrika@netscape.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef MSG_MAPI_SUPPORT_H_
|
||||
#define MSG_MAPI_SUPPORT_H_
|
||||
|
||||
#include "nsIObserver.h"
|
||||
#include "nsIMapiSupport.h"
|
||||
#include "msgMapiFactory.h"
|
||||
|
||||
#define NS_IMAPISUPPORT_CID \
|
||||
{0x8967fed2, 0xc8bb, 0x11d5, \
|
||||
{ 0xa3, 0xe9, 0x00, 0xb0, 0xd0, 0xf3, 0xba, 0xa7 }}
|
||||
|
||||
class nsMapiSupport : public nsIMapiSupport,
|
||||
public nsIObserver
|
||||
{
|
||||
public :
|
||||
nsMapiSupport();
|
||||
~nsMapiSupport();
|
||||
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
NS_DECL_NSIMAPISUPPORT
|
||||
|
||||
private :
|
||||
|
||||
DWORD m_dwRegister;
|
||||
CMapiFactory *m_nsMapiFactory;
|
||||
};
|
||||
|
||||
#endif // MSG_MAPI_SUPPORT_H_
|
||||
@@ -1,167 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsIProxyObjectManager.h"
|
||||
#include "nsProxiedService.h"
|
||||
|
||||
#include "nsMapiRegistryUtils.h"
|
||||
#include "nsMapiRegistry.h"
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
/** Implementation of the nsIMapiRegistry interface.
|
||||
* Use standard implementation of nsISupports stuff.
|
||||
*/
|
||||
NS_IMPL_ISUPPORTS1(nsMapiRegistry, nsIMapiRegistry);
|
||||
|
||||
nsMapiRegistry::nsMapiRegistry() {
|
||||
NS_INIT_ISUPPORTS();
|
||||
m_ShowDialog = ! m_registryUtils.verifyRestrictedAccess();
|
||||
m_DefaultMailClient = m_registryUtils.IsDefaultMailClient();
|
||||
}
|
||||
|
||||
nsMapiRegistry::~nsMapiRegistry() {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiRegistry::GetIsDefaultMailClient(PRBool * retval) {
|
||||
// we need to get the value from registry everytime
|
||||
// because the registry settings can be changed from
|
||||
// other mail applications.
|
||||
*retval = m_registryUtils.IsDefaultMailClient();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiRegistry::GetShowDialog(PRBool * retval) {
|
||||
*retval = m_ShowDialog;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMapiRegistry::SetIsDefaultMailClient(PRBool aIsDefaultMailClient)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (aIsDefaultMailClient)
|
||||
{
|
||||
rv = m_registryUtils.setDefaultMailClient();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
m_DefaultMailClient = PR_TRUE;
|
||||
else
|
||||
m_registryUtils.ShowMapiErrorDialog();
|
||||
}
|
||||
else
|
||||
{
|
||||
rv = m_registryUtils.unsetDefaultMailClient();
|
||||
if (NS_SUCCEEDED(rv))
|
||||
m_DefaultMailClient = PR_FALSE;
|
||||
else
|
||||
m_registryUtils.ShowMapiErrorDialog();
|
||||
}
|
||||
|
||||
return rv ;
|
||||
}
|
||||
|
||||
/** This will bring up the dialog box only once per session and
|
||||
* only if the current app is not default Mail Client.
|
||||
* This also checks the registry if the registry key
|
||||
* showMapiDialog is set
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsMapiRegistry::ShowMailIntegrationDialog(nsIDOMWindow *aParentWindow) {
|
||||
nsresult rv;
|
||||
if (!m_ShowDialog || !m_registryUtils.getShowDialog()) return NS_OK;
|
||||
nsCOMPtr<nsIPromptService> promptService(do_GetService(
|
||||
"@mozilla.org/embedcomp/prompt-service;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && promptService)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = m_registryUtils.MakeMapiStringBundle (getter_AddRefs (bundle)) ;
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString dialogTitle;
|
||||
const PRUnichar *brandStrings[] = { m_registryUtils.brandName() };
|
||||
NS_NAMED_LITERAL_STRING(dialogTitlePropertyTag, "dialogTitle");
|
||||
rv = bundle->FormatStringFromName(dialogTitlePropertyTag.get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogTitle));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString dialogText;
|
||||
NS_NAMED_LITERAL_STRING(dialogTextPropertyTag, "dialogText");
|
||||
rv = bundle->FormatStringFromName(dialogTextPropertyTag.get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogText));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString checkboxText;
|
||||
rv = bundle->GetStringFromName(
|
||||
NS_LITERAL_STRING("checkboxText").get(),
|
||||
getter_Copies(checkboxText));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
PRBool checkValue = PR_FALSE;
|
||||
PRInt32 buttonPressed = 0;
|
||||
rv = promptService->ConfirmEx(aParentWindow,
|
||||
dialogTitle,
|
||||
dialogText.get(),
|
||||
(nsIPromptService::BUTTON_TITLE_YES *
|
||||
nsIPromptService::BUTTON_POS_0) +
|
||||
(nsIPromptService::BUTTON_TITLE_NO *
|
||||
nsIPromptService::BUTTON_POS_1),
|
||||
nsnull,
|
||||
nsnull,
|
||||
nsnull,
|
||||
checkboxText,
|
||||
&checkValue,
|
||||
&buttonPressed);
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
rv = m_registryUtils.SetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Mozilla\\Desktop",
|
||||
"showMapiDialog", (checkValue) ? "0" : "1");
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
m_ShowDialog = PR_FALSE;
|
||||
if (!buttonPressed)
|
||||
rv = SetIsDefaultMailClient(PR_TRUE) ; // SetDefaultMailClient();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsmapiregistry_h____
|
||||
#define nsmapiregistry_h____
|
||||
|
||||
#include "nsIMapiRegistry.h"
|
||||
|
||||
#ifndef MAX_BUF
|
||||
#define MAX_BUF 4096
|
||||
#endif
|
||||
|
||||
/* c5be14ba-4e0a-4eec-a1b8-04363761d63c */
|
||||
#define NS_IMAPIREGISTRY_CID \
|
||||
{ 0xc5be14ba, 0x4e0a, 0x4eec, {0xa1, 0xb8, 0x04, 0x36, 0x37, 0x61, 0xd6, 0x3c} }
|
||||
#define NS_IMAPIREGISTRY_CONTRACTID "@mozilla.org/mapiregistry;1"
|
||||
#define NS_IMAPIREGISTRY_CLASSNAME "Mozilla MAPI Registry"
|
||||
|
||||
#define MAILNEWS_ALLOW_DEFAULT_MAIL_CLIENT "mailnews.default_mail_client"
|
||||
|
||||
class nsMapiRegistry : public nsIMapiRegistry {
|
||||
public:
|
||||
// ctor/dtor
|
||||
nsMapiRegistry();
|
||||
virtual ~nsMapiRegistry();
|
||||
|
||||
// Declare all interface methods we must implement.
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIMAPIREGISTRY
|
||||
|
||||
protected:
|
||||
|
||||
PRBool m_DefaultMailClient;
|
||||
PRBool m_ShowDialog;
|
||||
nsMapiRegistryUtils m_registryUtils ;
|
||||
|
||||
private:
|
||||
// Special member to handle initialization.
|
||||
PRBool mHaveBeenSet;
|
||||
}; // nsMapiRegistry
|
||||
|
||||
#endif // nsmapiregistry_h____
|
||||
@@ -1,743 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#undef UNICODE
|
||||
#undef _UNICODE
|
||||
|
||||
#include "nsIServiceManager.h"
|
||||
#include "msgMapiImp.h"
|
||||
#include "msgMapiMain.h"
|
||||
#include "nsMapiRegistryUtils.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringBundle.h"
|
||||
#include "nsIPromptService.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsSpecialSystemDirectory.h"
|
||||
#include "nsDirectoryService.h"
|
||||
#include "nsDirectoryServiceDefs.h"
|
||||
#include "nsAppDirectoryServiceDefs.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_CID(kStringBundleServiceCID, NS_STRINGBUNDLESERVICE_CID);
|
||||
|
||||
#define EXE_EXTENSION ".exe"
|
||||
#define USERAGENT_VERSION_PREF "general.useragent.misc"
|
||||
#define USERAGENT_VERSION_NS_PREF "general.useragent.vendorSub"
|
||||
#define USERAGENT_PREF_PREFIX "rv:"
|
||||
|
||||
nsMapiRegistryUtils::nsMapiRegistryUtils()
|
||||
{
|
||||
m_mapiStringBundle = nsnull ;
|
||||
}
|
||||
|
||||
const char * nsMapiRegistryUtils::thisApplication()
|
||||
{
|
||||
if (m_thisApp.IsEmpty()) {
|
||||
char buffer[MAX_PATH] = {0};
|
||||
DWORD len = ::GetModuleFileName(NULL, buffer, MAX_PATH);
|
||||
if (!len) return nsnull ;
|
||||
char shortPathBuf[MAX_PATH] = {0};
|
||||
len = ::GetShortPathName(buffer, shortPathBuf, MAX_PATH);
|
||||
if (!len) return nsnull ;
|
||||
m_thisApp = buffer;
|
||||
m_thisApp.ToUpperCase();
|
||||
}
|
||||
|
||||
return m_thisApp.get() ;
|
||||
}
|
||||
|
||||
const PRUnichar * nsMapiRegistryUtils::brandName()
|
||||
{
|
||||
nsresult rv;
|
||||
if (m_brand.IsEmpty()) {
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
|
||||
kStringBundleServiceCID, &rv));
|
||||
if (NS_SUCCEEDED(rv) && bundleService) {
|
||||
nsCOMPtr<nsIStringBundle> brandBundle;
|
||||
rv = bundleService->CreateBundle(
|
||||
"chrome://global/locale/brand.properties",
|
||||
getter_AddRefs(brandBundle));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsXPIDLString brandName;
|
||||
rv = brandBundle->GetStringFromName(
|
||||
NS_LITERAL_STRING("brandShortName").get(),
|
||||
getter_Copies(brandName));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
m_brand = brandName ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_brand.get() ;
|
||||
}
|
||||
|
||||
const PRUnichar * nsMapiRegistryUtils::versionNo()
|
||||
{
|
||||
if (!m_versionNo.IsEmpty())
|
||||
return m_versionNo.get() ;
|
||||
|
||||
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (prefs) {
|
||||
nsXPIDLCString versionStr ;
|
||||
nsresult rv = prefs->GetCharPref(USERAGENT_VERSION_NS_PREF, getter_Copies(versionStr));
|
||||
if (NS_SUCCEEDED(rv) && versionStr)
|
||||
m_versionNo.AssignWithConversion (versionStr.get()) ;
|
||||
else {
|
||||
rv = prefs->GetCharPref(USERAGENT_VERSION_PREF, getter_Copies(versionStr));
|
||||
if (NS_SUCCEEDED(rv) && versionStr) {
|
||||
m_versionNo.AssignWithConversion (versionStr.get()) ;
|
||||
m_versionNo.StripChars (USERAGENT_PREF_PREFIX) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return m_versionNo.get() ;
|
||||
}
|
||||
|
||||
|
||||
PRBool nsMapiRegistryUtils::verifyRestrictedAccess() {
|
||||
char subKey[] = "Software\\Mozilla - Test Key";
|
||||
PRBool result = PR_FALSE;
|
||||
DWORD dwDisp = 0;
|
||||
HKEY key;
|
||||
// Try to create/open a subkey under HKLM.
|
||||
DWORD rc = ::RegCreateKeyEx(HKEY_LOCAL_MACHINE,
|
||||
subKey,
|
||||
0,
|
||||
NULL,
|
||||
REG_OPTION_NON_VOLATILE,
|
||||
KEY_WRITE,
|
||||
NULL,
|
||||
&key,
|
||||
&dwDisp);
|
||||
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
// Key was opened; first close it.
|
||||
::RegCloseKey(key);
|
||||
// Delete it if we just created it.
|
||||
switch(dwDisp) {
|
||||
case REG_CREATED_NEW_KEY:
|
||||
::RegDeleteKey(HKEY_LOCAL_MACHINE, subKey);
|
||||
break;
|
||||
case REG_OPENED_EXISTING_KEY:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Can't create/open it; we don't have access.
|
||||
result = PR_TRUE;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::SetRegistryKey(HKEY baseKey, const char * keyName,
|
||||
const char * valueName, char * value)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
HKEY key;
|
||||
LONG rc = ::RegCreateKey(baseKey, keyName, &key);
|
||||
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
rc = ::RegSetValueEx(key, valueName, NULL, REG_SZ,
|
||||
(LPBYTE)(const char*)value, strlen(value));
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
result = NS_OK;
|
||||
}
|
||||
::RegCloseKey(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::DeleteRegistryValue(HKEY baseKey, const char * keyName,
|
||||
const char * valueName)
|
||||
{
|
||||
nsresult result = NS_ERROR_FAILURE;
|
||||
HKEY key;
|
||||
LONG rc = ::RegOpenKey(baseKey, keyName, &key);
|
||||
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
rc = ::RegDeleteValue(key, valueName);
|
||||
if (rc == ERROR_SUCCESS)
|
||||
result = NS_OK;
|
||||
::RegCloseKey(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void nsMapiRegistryUtils::GetRegistryKey(HKEY baseKey, const char * keyName,
|
||||
const char * valueName, nsCAutoString & value)
|
||||
{
|
||||
HKEY key;
|
||||
LONG rc = ::RegOpenKey(baseKey, keyName, &key);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
char buffer[MAX_PATH] = {0};
|
||||
DWORD len = sizeof buffer;
|
||||
rc = ::RegQueryValueEx(key, valueName, NULL, NULL,
|
||||
(LPBYTE)buffer, &len);
|
||||
if (rc == ERROR_SUCCESS) {
|
||||
if (len)
|
||||
value = buffer;
|
||||
}
|
||||
::RegCloseKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool nsMapiRegistryUtils::IsDefaultMailClient()
|
||||
{
|
||||
if (!isSmartDll() && !isMozDll())
|
||||
return PR_FALSE;
|
||||
nsCAutoString name;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Clients\\Mail", "", name);
|
||||
if (!name.IsEmpty()) {
|
||||
nsCAutoString keyName("Software\\Clients\\Mail\\");
|
||||
keyName += name.get();
|
||||
keyName += "\\protocols\\mailto\\shell\\open\\command";
|
||||
|
||||
nsCAutoString result;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", result);
|
||||
if (!result.IsEmpty()) {
|
||||
nsCAutoString strExtension;
|
||||
strExtension.Assign(EXE_EXTENSION);
|
||||
result.ToUpperCase();
|
||||
strExtension.ToUpperCase();
|
||||
PRInt32 index = result.RFind(strExtension.get());
|
||||
if (index != kNotFound) {
|
||||
result.Truncate(index + strExtension.Length());
|
||||
}
|
||||
nsCAutoString thisApp (thisApplication()) ;
|
||||
return (result == thisApp);
|
||||
}
|
||||
}
|
||||
return PR_FALSE;
|
||||
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::saveDefaultMailClient()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString name ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE,"Software\\Clients\\Mail", "", name);
|
||||
if (!name.IsEmpty()) {
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail",
|
||||
(char *)name.get());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString keyName("Software\\Clients\\Mail\\");
|
||||
keyName += name.get();
|
||||
keyName += "\\protocols\\mailto\\shell\\open\\command";
|
||||
nsCAutoString appPath ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, keyName.get(), "", appPath);
|
||||
if (!appPath.IsEmpty()) {
|
||||
nsCAutoString stringName("HKEY_LOCAL_MACHINE\\");
|
||||
stringName += keyName.get();
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
stringName.get(), (char *)appPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail",
|
||||
"");
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::saveUserDefaultMailClient()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCAutoString name ;
|
||||
GetRegistryKey(HKEY_CURRENT_USER,"Software\\Clients\\Mail", "", name);
|
||||
if (!name.IsEmpty()) {
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"HKEY_CURRENT_USER\\Software\\Clients\\Mail",
|
||||
(char *)name.get());
|
||||
}
|
||||
else {
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"HKEY_CURRENT_USER\\Software\\Clients\\Mail",
|
||||
"");
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether it is a smart dll or not. Smart dll is the one installed by
|
||||
* IE5 or Outlook Express which forwards the MAPI calls to the dll based on the
|
||||
* registry key setttings.
|
||||
* Returns TRUE if is a smart dll.
|
||||
*/
|
||||
|
||||
typedef HRESULT (FAR PASCAL GetOutlookVersionFunc)();
|
||||
PRBool nsMapiRegistryUtils::isSmartDll()
|
||||
{
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
|
||||
return PR_FALSE;
|
||||
PL_strcatn(buffer, sizeof(buffer), "\\Mapi32.dll");
|
||||
|
||||
HINSTANCE hInst;
|
||||
GetOutlookVersionFunc *doesExist = nsnull;
|
||||
hInst = LoadLibrary(buffer);
|
||||
if (hInst == nsnull)
|
||||
return PR_FALSE;
|
||||
|
||||
doesExist = (GetOutlookVersionFunc *) GetProcAddress (hInst, "GetOutlookVersion");
|
||||
FreeLibrary(hInst);
|
||||
|
||||
return (doesExist != nsnull);
|
||||
}
|
||||
|
||||
typedef HRESULT (FAR PASCAL GetMapiDllVersion)();
|
||||
/**
|
||||
* Checks whether mapi32.dll is installed by this app.
|
||||
* Returns TRUE if it is.
|
||||
*/
|
||||
PRBool nsMapiRegistryUtils::isMozDll()
|
||||
{
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
|
||||
return PR_FALSE;
|
||||
PL_strcatn(buffer, sizeof(buffer), "\\Mapi32.dll");
|
||||
|
||||
HINSTANCE hInst;
|
||||
GetMapiDllVersion *doesExist = nsnull;
|
||||
hInst = LoadLibrary(buffer);
|
||||
if (hInst == nsnull)
|
||||
return PR_FALSE;
|
||||
|
||||
doesExist = (GetMapiDllVersion *) GetProcAddress (hInst, "GetMapiDllVersion");
|
||||
FreeLibrary(hInst);
|
||||
|
||||
return (doesExist != nsnull);
|
||||
}
|
||||
|
||||
/** Renames Mapi32.dl in system directory to Mapi32_moz_bak.dll
|
||||
* copies the mozMapi32.dll from bin directory to the system directory
|
||||
*/
|
||||
nsresult nsMapiRegistryUtils::CopyMozMapiToWinSysDir()
|
||||
{
|
||||
nsresult rv;
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString filePath(buffer);
|
||||
filePath.Append("\\Mapi32_moz_bak.dll");
|
||||
|
||||
nsCOMPtr<nsILocalFile> pCurrentMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pCurrentMapiFile) return rv;
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
|
||||
nsCOMPtr<nsIFile> pMozMapiFile;
|
||||
nsCOMPtr<nsIProperties> directoryService =
|
||||
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID, &rv);
|
||||
if (!directoryService) return NS_ERROR_FAILURE;
|
||||
rv = directoryService->Get(NS_OS_CURRENT_PROCESS_DIR,
|
||||
NS_GET_IID(nsIFile),
|
||||
getter_AddRefs(pMozMapiFile));
|
||||
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
pMozMapiFile->Append("mozMapi32.dll");
|
||||
|
||||
PRBool bExist;
|
||||
rv = pMozMapiFile->Exists(&bExist);
|
||||
if (NS_FAILED(rv) || !bExist) return rv;
|
||||
|
||||
rv = pCurrentMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist)
|
||||
{
|
||||
rv = pCurrentMapiFile->Remove(PR_FALSE);
|
||||
}
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
filePath.Assign(buffer);
|
||||
filePath.Append("\\Mapi32.dll");
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
rv = pCurrentMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist)
|
||||
{
|
||||
rv = pCurrentMapiFile->MoveTo(nsnull, "Mapi32_moz_bak.dll");
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCAutoString fullFilePath(buffer);
|
||||
fullFilePath.Append("\\Mapi32_moz_bak.dll");
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"Mapi_backup_dll",
|
||||
(char *)fullFilePath.get());
|
||||
if (NS_FAILED(rv)) {
|
||||
RestoreBackedUpMapiDll();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
NS_NAMED_LITERAL_STRING(fileName, "Mapi32.dll");
|
||||
filePath.Assign(buffer);
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
rv = pMozMapiFile->CopyToUnicode(pCurrentMapiFile, fileName.get());
|
||||
if (NS_FAILED(rv))
|
||||
RestoreBackedUpMapiDll();
|
||||
return rv;
|
||||
}
|
||||
|
||||
/** deletes the Mapi32.dll in system directory and renames Mapi32_moz_bak.dll
|
||||
* to Mapi32.dll
|
||||
*/
|
||||
nsresult nsMapiRegistryUtils::RestoreBackedUpMapiDll()
|
||||
{
|
||||
nsresult rv;
|
||||
char buffer[MAX_PATH] = {0};
|
||||
if (GetSystemDirectory(buffer, sizeof(buffer)) == 0)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString filePath(buffer);
|
||||
nsCAutoString previousFileName(buffer);
|
||||
filePath.Append("\\Mapi32.dll");
|
||||
previousFileName.Append("\\Mapi32_moz_bak.dll");
|
||||
|
||||
nsCOMPtr <nsILocalFile> pCurrentMapiFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pCurrentMapiFile) return NS_ERROR_FAILURE;
|
||||
pCurrentMapiFile->InitWithPath(filePath.get());
|
||||
|
||||
nsCOMPtr<nsILocalFile> pPreviousMapiFile = do_CreateInstance (NS_LOCAL_FILE_CONTRACTID, &rv);
|
||||
if (NS_FAILED(rv) || !pPreviousMapiFile) return NS_ERROR_FAILURE;
|
||||
pPreviousMapiFile->InitWithPath(previousFileName.get());
|
||||
|
||||
PRBool bExist;
|
||||
rv = pCurrentMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist) {
|
||||
rv = pCurrentMapiFile->Remove(PR_FALSE);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
}
|
||||
|
||||
rv = pPreviousMapiFile->Exists(&bExist);
|
||||
if (NS_SUCCEEDED(rv) && bExist)
|
||||
rv = pPreviousMapiFile->MoveTo(nsnull, "Mapi32.dll");
|
||||
if (NS_SUCCEEDED(rv))
|
||||
DeleteRegistryValue(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"Mapi_backup_dll");
|
||||
return rv;
|
||||
}
|
||||
|
||||
/** Sets Mozilla as default Mail Client
|
||||
*/
|
||||
nsresult nsMapiRegistryUtils::setDefaultMailClient()
|
||||
{
|
||||
nsresult rv;
|
||||
nsresult mailKeySet=NS_ERROR_FAILURE;
|
||||
if (verifyRestrictedAccess()) return NS_ERROR_FAILURE;
|
||||
if (!isSmartDll()) {
|
||||
if (NS_FAILED(CopyMozMapiToWinSysDir())) return NS_ERROR_FAILURE;
|
||||
}
|
||||
rv = saveDefaultMailClient();
|
||||
if (NS_FAILED(saveUserDefaultMailClient()) ||
|
||||
NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
nsCAutoString keyName("Software\\Clients\\Mail\\");
|
||||
|
||||
nsCAutoString appName (NS_ConvertUCS2toUTF8(brandName()).get());
|
||||
if (!appName.IsEmpty()) {
|
||||
keyName.Append(appName.get());
|
||||
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = MakeMapiStringBundle (getter_AddRefs (bundle)) ;
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString defaultMailTitle;
|
||||
const PRUnichar *keyValuePrefixStr[] = { brandName(), versionNo() };
|
||||
NS_NAMED_LITERAL_STRING(defaultMailTitleTag, "defaultMailDisplayTitle");
|
||||
rv = bundle->FormatStringFromName(defaultMailTitleTag.get(),
|
||||
keyValuePrefixStr, 2,
|
||||
getter_Copies(defaultMailTitle));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(),
|
||||
"", NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(defaultMailTitle).get()) ) ;
|
||||
}
|
||||
else
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString thisApp (thisApplication()) ;
|
||||
if (NS_FAILED(rv)) return rv ;
|
||||
|
||||
nsCAutoString dllPath (thisApp) ;
|
||||
PRInt32 index = dllPath.RFind("\\");
|
||||
if (index != kNotFound)
|
||||
dllPath.Truncate(index + 1);
|
||||
dllPath += "mozMapi32.dll";
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(), "DLLPath",
|
||||
(char *)dllPath.get());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
keyName.Append("\\protocols\\mailto");
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(),
|
||||
"", "URL:MailTo Protocol");
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString appPath (thisApp);
|
||||
appPath += " \"%1\"";
|
||||
keyName.Append("\\shell\\open\\command");
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(),
|
||||
"", (char *)appPath.get());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Clients\\Mail",
|
||||
"", (char *)appName.get());
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString mailAppPath(thisApp);
|
||||
mailAppPath += " -mail";
|
||||
nsCAutoString appKeyName ("Software\\Clients\\Mail\\");
|
||||
appKeyName.Append(appName.get());
|
||||
appKeyName.Append("\\shell\\open\\command");
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
appKeyName.get(),
|
||||
"", (char *)mailAppPath.get());
|
||||
}
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCAutoString iconPath(thisApp);
|
||||
iconPath += ",0";
|
||||
nsCAutoString iconKeyName ("Software\\Clients\\Mail\\");
|
||||
iconKeyName.Append(appName.get());
|
||||
iconKeyName.Append("\\DefaultIcon");
|
||||
mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
iconKeyName.get(),
|
||||
"", (char *)iconPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(mailKeySet)) {
|
||||
nsresult desktopKeySet = SetRegistryKey(HKEY_CURRENT_USER,
|
||||
"Software\\Clients\\Mail",
|
||||
"", (char *)appName.get());
|
||||
if (NS_SUCCEEDED(desktopKeySet)) {
|
||||
desktopKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"defaultMailHasBeenSet", "1");
|
||||
}
|
||||
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
|
||||
(LPARAM)"Software\\Clients\\Mail");
|
||||
RegisterServer(CLSID_CMapiImp, "Mozilla MAPI", "mozMapi", "mozMapi.1");
|
||||
return desktopKeySet;
|
||||
}
|
||||
|
||||
return mailKeySet;
|
||||
}
|
||||
|
||||
/** Removes Mozilla as the default Mail client and restores the previous setting
|
||||
*/
|
||||
nsresult nsMapiRegistryUtils::unsetDefaultMailClient() {
|
||||
nsresult result = NS_OK;
|
||||
nsresult mailKeySet = NS_ERROR_FAILURE;
|
||||
if (verifyRestrictedAccess()) return NS_ERROR_FAILURE;
|
||||
if (!isSmartDll()) {
|
||||
if (NS_FAILED(RestoreBackedUpMapiDll())) return NS_ERROR_FAILURE;
|
||||
}
|
||||
nsCAutoString name ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Mozilla\\Desktop",
|
||||
"HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail", name);
|
||||
nsCAutoString appName (NS_ConvertUCS2toUTF8(brandName()).get());
|
||||
|
||||
if (!name.IsEmpty() && !appName.IsEmpty() && name.Equals(appName)) {
|
||||
nsCAutoString keyName("HKEY_LOCAL_MACHINE\\Software\\Clients\\Mail\\");
|
||||
keyName.Append(appName.get());
|
||||
keyName.Append("\\protocols\\mailto\\shell\\open\\command");
|
||||
nsCAutoString appPath ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Mozilla\\Desktop",
|
||||
keyName.get(), appPath);
|
||||
if (!appPath.IsEmpty()) {
|
||||
keyName.Assign("Software\\Clients\\Mail\\");
|
||||
keyName.Append(appName.get());
|
||||
keyName.Append("\\protocols\\mailto\\shell\\open\\command");
|
||||
result = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(),
|
||||
"", (char *)appPath.get());
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
PRInt32 index = appPath.RFind("\\");
|
||||
if (index != kNotFound)
|
||||
appPath.Truncate(index + 1);
|
||||
appPath += "mozMapi32.dll";
|
||||
keyName.Assign("Software\\Clients\\Mail\\");
|
||||
keyName.Append(appName.get());
|
||||
result = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
keyName.get(),
|
||||
"DLLPath", (char *) appPath.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!name.IsEmpty()) {
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Clients\\Mail",
|
||||
"", (char *)name.get());
|
||||
}
|
||||
}
|
||||
else
|
||||
mailKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Clients\\Mail",
|
||||
"", "");
|
||||
|
||||
if (NS_SUCCEEDED(mailKeySet)) {
|
||||
nsCAutoString userAppName ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"HKEY_CURRENT_USER\\Software\\Clients\\Mail", userAppName);
|
||||
nsresult desktopKeySet = NS_OK;
|
||||
if (!userAppName.IsEmpty()) {
|
||||
desktopKeySet = SetRegistryKey(HKEY_CURRENT_USER,
|
||||
"Software\\Clients\\Mail",
|
||||
"", (char *)userAppName.get());
|
||||
}
|
||||
else {
|
||||
DeleteRegistryValue(HKEY_CURRENT_USER, "Software\\Clients\\Mail", "");
|
||||
}
|
||||
if (NS_SUCCEEDED(desktopKeySet)) {
|
||||
desktopKeySet = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"defaultMailHasBeenSet", "0");
|
||||
}
|
||||
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0,
|
||||
(LPARAM)"Software\\Clients\\Mail");
|
||||
UnregisterServer(CLSID_CMapiImp, "mozMapi", "mozMapi.1");
|
||||
return desktopKeySet;
|
||||
}
|
||||
return mailKeySet;
|
||||
}
|
||||
|
||||
/** Returns FALSE if showMapiDialog is set to 0.
|
||||
* Returns TRUE otherwise
|
||||
* Also returns TRUE if the Mozilla has been set as the default mail client
|
||||
* and some other application has changed that setting.
|
||||
* This function gets called only if the current app is not the default mail
|
||||
* client
|
||||
*/
|
||||
PRBool nsMapiRegistryUtils::getShowDialog() {
|
||||
PRBool rv = PR_FALSE;
|
||||
nsCAutoString showDialog ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE, "Software\\Mozilla\\Desktop",
|
||||
"showMapiDialog", showDialog);
|
||||
// if the user has not selected the checkbox, show dialog
|
||||
if (showDialog.IsEmpty() || showDialog.Equals("1"))
|
||||
rv = PR_TRUE;
|
||||
|
||||
if (!rv) {
|
||||
// even if the user has selected the checkbox
|
||||
// show it if some other application has changed the
|
||||
// default setting.
|
||||
nsCAutoString setMailDefault ;
|
||||
GetRegistryKey(HKEY_LOCAL_MACHINE,"Software\\Mozilla\\Desktop",
|
||||
"defaultMailHasBeenSet", setMailDefault);
|
||||
if (setMailDefault.Equals("1")) {
|
||||
// need to reset the defaultMailHasBeenSet to "0"
|
||||
// so that after the dialog is displayed once,
|
||||
// we do not keep displaying this dialog after the user has
|
||||
// selected the checkbox
|
||||
rv = SetRegistryKey(HKEY_LOCAL_MACHINE,
|
||||
"Software\\Mozilla\\Desktop",
|
||||
"defaultMailHasBeenSet", "0");
|
||||
rv = PR_TRUE;
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::MakeMapiStringBundle(nsIStringBundle ** aMapiStringBundle)
|
||||
{
|
||||
nsresult rv = NS_OK ;
|
||||
|
||||
if (m_mapiStringBundle)
|
||||
{
|
||||
*aMapiStringBundle = m_mapiStringBundle ;
|
||||
NS_ADDREF(*aMapiStringBundle);
|
||||
return rv ;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStringBundleService> bundleService(do_GetService(
|
||||
kStringBundleServiceCID, &rv));
|
||||
if (NS_FAILED(rv) || !bundleService) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = bundleService->CreateBundle(
|
||||
MAPI_PROPERTIES_CHROME,
|
||||
getter_AddRefs(m_mapiStringBundle));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
NS_ADDREF(*aMapiStringBundle = m_mapiStringBundle) ;
|
||||
|
||||
return rv ;
|
||||
}
|
||||
|
||||
nsresult nsMapiRegistryUtils::ShowMapiErrorDialog()
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIPromptService> promptService(do_GetService(
|
||||
"@mozilla.org/embedcomp/prompt-service;1", &rv));
|
||||
if (NS_SUCCEEDED(rv) && promptService)
|
||||
{
|
||||
nsCOMPtr<nsIStringBundle> bundle;
|
||||
rv = MakeMapiStringBundle (getter_AddRefs (bundle)) ;
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString dialogTitle;
|
||||
const PRUnichar *brandStrings[] = { brandName() };
|
||||
NS_NAMED_LITERAL_STRING(dialogTitlePropertyTag, "errorMessageTitle");
|
||||
rv = bundle->FormatStringFromName(dialogTitlePropertyTag.get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogTitle));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
nsXPIDLString dialogText;
|
||||
NS_NAMED_LITERAL_STRING(dialogTextPropertyTag, "errorMessage");
|
||||
rv = bundle->FormatStringFromName(dialogTextPropertyTag.get(),
|
||||
brandStrings, 1,
|
||||
getter_Copies(dialogText));
|
||||
if (NS_FAILED(rv)) return NS_ERROR_FAILURE;
|
||||
|
||||
rv = promptService->Alert(nsnull, dialogTitle,
|
||||
dialogText);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -1,112 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsmapiregistryutils_h____
|
||||
#define nsmapiregistryutils_h____
|
||||
|
||||
#include <windows.h>
|
||||
#include <string.h>
|
||||
#include <winreg.h>
|
||||
|
||||
#include "Registry.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIStringBundle.h"
|
||||
|
||||
class nsMapiRegistryUtils
|
||||
{
|
||||
private :
|
||||
nsCAutoString m_thisApp ;
|
||||
nsAutoString m_brand ;
|
||||
nsAutoString m_versionNo ;
|
||||
|
||||
nsCOMPtr<nsIStringBundle> m_mapiStringBundle ;
|
||||
public :
|
||||
nsMapiRegistryUtils() ;
|
||||
|
||||
// returns TRUE if the Mapi32.dll is smart dll.
|
||||
PRBool isSmartDll();
|
||||
// returns TRUE if the Mapi32.dll is a Mozilla dll.
|
||||
PRBool isMozDll();
|
||||
|
||||
// Returns the (fully-qualified) name of this executable.
|
||||
const char * thisApplication() ;
|
||||
// This returns the brand name for this application
|
||||
const PRUnichar * brandName() ;
|
||||
// This returns the version no for this application
|
||||
const PRUnichar * versionNo() ;
|
||||
// verifyRestrictedAccess - Returns PR_TRUE if this user only has restricted access
|
||||
// to the registry keys we need to modify.
|
||||
PRBool verifyRestrictedAccess() ;
|
||||
|
||||
// set the Windows registry key
|
||||
nsresult SetRegistryKey(HKEY baseKey, const char * keyName,
|
||||
const char * valueName, char * value);
|
||||
// delete a registry key
|
||||
nsresult DeleteRegistryValue(HKEY baseKey, const char * keyName,
|
||||
const char * valueName);
|
||||
// get a Windows registry key
|
||||
void GetRegistryKey(HKEY baseKey, const char * keyName,
|
||||
const char * valueName, nsCAutoString & value) ;
|
||||
|
||||
// Returns TRUE if the current application is default mail client.
|
||||
PRBool IsDefaultMailClient();
|
||||
// Sets Mozilla as default Mail Client
|
||||
nsresult setDefaultMailClient() ;
|
||||
// Removes Mozilla as the default Mail client and restores the previous setting
|
||||
nsresult unsetDefaultMailClient() ;
|
||||
|
||||
// Saves the current setting of the default Mail Client in
|
||||
// HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop
|
||||
nsresult saveDefaultMailClient();
|
||||
// Saves the current user setting of the default Mail Client in
|
||||
// HKEY_LOCAL_MACHINE\\Software\\Mozilla\\Desktop
|
||||
nsresult saveUserDefaultMailClient();
|
||||
|
||||
nsresult CopyMozMapiToWinSysDir();
|
||||
nsresult RestoreBackedUpMapiDll();
|
||||
|
||||
// Returns FALSE if showMapiDialog is set to 0.
|
||||
PRBool getShowDialog() ;
|
||||
|
||||
// create a string bundle for MAPI messages
|
||||
nsresult MakeMapiStringBundle(nsIStringBundle ** aMapiStringBundle) ;
|
||||
// display an error dialog for MAPI messages
|
||||
nsresult ShowMapiErrorDialog() ;
|
||||
|
||||
} ;
|
||||
|
||||
#endif
|
||||
@@ -1,30 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the packages being supplied by this jar -->
|
||||
<RDF:Seq about="urn:mozilla:package:root">
|
||||
<RDF:li resource="urn:mozilla:package:messenger-mapi"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- package information -->
|
||||
<RDF:Description about="urn:mozilla:package:messenger-mapi"
|
||||
chrome:displayName="Messenger"
|
||||
chrome:author="mozilla.org"
|
||||
chrome:name="messenger-mapi"
|
||||
chrome:localeVersion="0.9.7"
|
||||
chrome:skinVersion="0.9.4">
|
||||
</RDF:Description>
|
||||
|
||||
<!-- overlay information -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://messenger/content/pref-mailnews.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- mapi items for Mail And Newsgroups preferences pane -->
|
||||
<RDF:Seq about="chrome://messenger/content/pref-mailnews.xul">
|
||||
<RDF:li>chrome://messenger-mapi/content/pref-mailnewsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
@@ -1,3 +0,0 @@
|
||||
messenger.jar:
|
||||
content/messenger-mapi/pref-mailnewsOverlay.xul
|
||||
content/messenger-mapi/contents.rdf
|
||||
@@ -1,29 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
chrome::
|
||||
$(REGCHROME) content messenger-mapi messenger.jar
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:chrome="http://www.mozilla.org/rdf/chrome#"
|
||||
xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
|
||||
<!-- mapi items for mailnews preferences -->
|
||||
<RDF:Seq about="urn:mozilla:overlays">
|
||||
<RDF:li resource="chrome://messenger/content/pref-mailnews.xul"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<RDF:Seq about="chrome://messenger/content/pref-mailnews.xul">
|
||||
<RDF:li>chrome://messenger/content/pref-mailnewsOverlay.xul</RDF:li>
|
||||
</RDF:Seq>
|
||||
|
||||
</RDF:RDF>
|
||||
@@ -1,104 +0,0 @@
|
||||
/*
|
||||
* The contents of this file are subject to the Mozilla Public
|
||||
* License Version 1.1 (the "License"); you may not use this file
|
||||
* except in compliance with the License. You may obtain a copy of
|
||||
* the License at http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS
|
||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
* implied. See the License for the specific language governing
|
||||
* rights and limitations under the License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Srilatha Moturi <srilatha@netscape.com>
|
||||
*/
|
||||
|
||||
function mailnewsOverlayStartup() {
|
||||
mailnewsOverlayInit();
|
||||
parent.hPrefWindow.registerOKCallbackFunc(onOK);
|
||||
if (!("mapiPref" in parent)) {
|
||||
parent.mapiPref = new Object;
|
||||
parent.mapiPref.isDefaultMailClient =
|
||||
document.getElementById("mailnewsEnableMapi").checked;
|
||||
}
|
||||
else {
|
||||
// when we switch between different panes
|
||||
// set the checkbox based on the saved state
|
||||
var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
|
||||
if (parent.mapiPref.isDefaultMailClient)
|
||||
mailnewsEnableMapi.setAttribute("checked", "true");
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("checked", "false");
|
||||
}
|
||||
}
|
||||
|
||||
function mailnewsOverlayInit() {
|
||||
try {
|
||||
var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
|
||||
getService( Components.interfaces.nsIMapiRegistry );
|
||||
}
|
||||
catch(ex){
|
||||
mapiRegistry = null;
|
||||
}
|
||||
|
||||
const prefbase = "system.windows.lock_ui.";
|
||||
var mailnewsEnableMapi = document.getElementById("mailnewsEnableMapi");
|
||||
if (mapiRegistry) {
|
||||
// initialise preference component.
|
||||
// While the data is coming from the system registry, we use a set
|
||||
// of parallel preferences to indicate if the ui should be locked.
|
||||
try {
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService()
|
||||
.QueryInterface(Components.interfaces.nsIPrefService);
|
||||
var prefBranch = prefService.getBranch(prefbase);
|
||||
if (prefBranch && prefBranch.prefIsLocked("default_mail_client")) {
|
||||
if (prefBranch.getBoolPref("default_mail_client"))
|
||||
mapiRegistry.setDefaultMailClient();
|
||||
else
|
||||
mapiRegistry.unsetDefaultMailClient();
|
||||
mailnewsEnableMapi.setAttribute("disabled", "true");
|
||||
}
|
||||
}
|
||||
catch(ex) {}
|
||||
if (mapiRegistry.isDefaultMailClient)
|
||||
mailnewsEnableMapi.setAttribute("checked", "true");
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("checked", "false");
|
||||
}
|
||||
else
|
||||
mailnewsEnableMapi.setAttribute("disabled", "true");
|
||||
}
|
||||
|
||||
function onEnableMapi() {
|
||||
// save the state of the checkbox
|
||||
if ("mapiPref" in parent)
|
||||
parent.mapiPref.isDefaultMailClient =
|
||||
document.getElementById("mailnewsEnableMapi").checked;
|
||||
}
|
||||
|
||||
function onOK()
|
||||
{
|
||||
try {
|
||||
var mapiRegistry = Components.classes[ "@mozilla.org/mapiregistry;1" ].
|
||||
getService( Components.interfaces.nsIMapiRegistry );
|
||||
}
|
||||
catch(ex){
|
||||
mapiRegistry = null;
|
||||
}
|
||||
if (mapiRegistry &&
|
||||
("mapiPref" in parent) &&
|
||||
(mapiRegistry.isDefaultMailClient != parent.mapiPref.isDefaultMailClient)) {
|
||||
if (parent.mapiPref.isDefaultMailClient)
|
||||
mapiRegistry.setDefaultMailClient();
|
||||
else
|
||||
mapiRegistry.unsetDefaultMailClient();
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
The contents of this file are subject to the Mozilla Public
|
||||
License Version 1.1 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a copy of
|
||||
the License at http://www.mozilla.org/MPL/
|
||||
|
||||
oftware distributed under the License is distributed on an "AS
|
||||
IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
implied. See the License for the specific language governing
|
||||
rights and limitations under the License.
|
||||
|
||||
The Original Code is mozilla.org code.
|
||||
The Initial Developer of the Original Code is Netscape
|
||||
Communications Corporation. Portions created by Netscape are
|
||||
Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
Rights Reserved.
|
||||
|
||||
Contributor(s):
|
||||
Srilatha Moturi <srilatha@netscape.com>
|
||||
-->
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://global/locale/brand.dtd" >
|
||||
%brandDTD;
|
||||
<!ENTITY % prefMailnewsOverlayDTD SYSTEM "chrome://messenger-mapi/locale/pref-mailnewsOverlay.dtd" >
|
||||
%prefMailnewsOverlayDTD;
|
||||
]>
|
||||
<overlay id="prefMailnewsOverlay"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script type="application/x-javascript">
|
||||
<![CDATA[
|
||||
_elementIDs.push("mailnewsEnableMapi");
|
||||
]]>
|
||||
</script>
|
||||
<script type="application/x-javascript" src="chrome://messenger-mapi/content/pref-mailnewsOverlay.js"/>
|
||||
<hbox autostretch="never" id="mapi">
|
||||
<checkbox id="mailnewsEnableMapi" label="&enableMapi.label;"
|
||||
accesskey="&enableMapi.accesskey;"
|
||||
preftype="bool" prefstring="mailnews.default_mail_client" prefattribute="checked"/>
|
||||
|
||||
</hbox>
|
||||
</overlay>
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0"?>
|
||||
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:chrome="http://www.mozilla.org/rdf/chrome#">
|
||||
|
||||
<!-- list all the skins being supplied by this package -->
|
||||
<RDF:Seq about="urn:mozilla:locale:root">
|
||||
<RDF:li resource="urn:mozilla:locale:en-US"/>
|
||||
</RDF:Seq>
|
||||
|
||||
<!-- locale information -->
|
||||
<RDF:Description about="urn:mozilla:locale:en-US">
|
||||
<chrome:packages>
|
||||
<RDF:Seq about="urn:mozilla:locale:en-US:packages">
|
||||
<RDF:li resource="urn:mozilla:locale:en-US:messenger-mapi"/>
|
||||
</RDF:Seq>
|
||||
</chrome:packages>
|
||||
</RDF:Description>
|
||||
|
||||
<!-- Version Information. State that we work only with major version of this
|
||||
package. -->
|
||||
<RDF:Description about="urn:mozilla:locale:en-US:messenger-mapi"
|
||||
chrome:localeVersion="0.9.7"/>
|
||||
</RDF:RDF>
|
||||
@@ -1,4 +0,0 @@
|
||||
en-US.jar:
|
||||
locale/en-US/messenger-mapi/pref-mailnewsOverlay.dtd
|
||||
locale/en-US/messenger-mapi/mapi.properties
|
||||
locale/en-US/messenger-mapi/contents.rdf
|
||||
@@ -1,40 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..\..
|
||||
|
||||
|
||||
CHROME_DIR=locales\en-US
|
||||
CHROME_L10N_DIR=messenger\locale
|
||||
|
||||
CHROME_L10N = \
|
||||
.\pref-mailnewsOverlay.dtd \
|
||||
.\mapi.properties \
|
||||
.\contents.rdf \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
|
||||
chrome::
|
||||
$(REGCHROME) locale en-US/messenger-mapi en-US.jar
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
# Mail Integration Dialog
|
||||
dialogTitle=%S Mail
|
||||
dialogText=Do you want to use %S as the default mail application?
|
||||
checkboxText=Do not display this dialog again
|
||||
|
||||
# MAPI Messages
|
||||
loginText=Please enter your password for %S:
|
||||
loginTextwithName=Please enter your username and password
|
||||
loginTitle=%S Mail
|
||||
PasswordTitle=%S Mail
|
||||
|
||||
# MAPI Error Messages
|
||||
errorMessage=%S Mail could not be set as the default mail application because a registry key could not be updated. Verify with your system administrator that you have write access to your system registry, and then try again.
|
||||
errorMessageTitle=%S Mail
|
||||
|
||||
# MAPI Security Messages
|
||||
mapiBlindSendWarning=Another application is attempting to send mail using your user profile. Are you sure you want to send mail?
|
||||
mapiBlindSendDontShowAgain=Warn me whenever other applications try to send mail from me
|
||||
|
||||
#Default Mail Display String
|
||||
# localization note, $1%S is the app name, $2%S is the version
|
||||
defaultMailDisplayTitle=%S %S Mail
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
<!ENTITY enableMapiTitle.label "When sending mail from other applications">
|
||||
<!ENTITY enableMapi.label "Use &vendorShortName; Mail as the default mail application.">
|
||||
<!ENTITY enableMapi.accesskey "u">
|
||||
@@ -1,28 +0,0 @@
|
||||
#!nmake
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..\..
|
||||
|
||||
DIRS=en-US
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
@@ -1,27 +0,0 @@
|
||||
#
|
||||
# The contents of this file are subject to the Mozilla Public
|
||||
# License Version 1.1 (the "License"); you may not use this file
|
||||
# except in compliance with the License. You may obtain a copy of
|
||||
# the License at http://www.mozilla.org/MPL/
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS
|
||||
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
||||
# implied. See the License for the specific language governing
|
||||
# rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is mozilla.org code.
|
||||
#
|
||||
# The Initial Developer of the Original Code is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 2001 Netscape Communications Corporation. All
|
||||
# Rights Reserved.
|
||||
#
|
||||
# Contributor(s):
|
||||
# Srilatha Moturi <srilatha@netscape.com>
|
||||
#
|
||||
|
||||
DEPTH=..\..\..
|
||||
|
||||
DIRS=content locale
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
9
mozilla/modules/rdf/Makefile
Normal file
@@ -0,0 +1,9 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
|
||||
DIRS = include src
|
||||
|
||||
INCLUDE = $(INCLUDE) -I$(DEPTH)/modules/libimg/public
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
14
mozilla/modules/rdf/Makefile.in
Normal file
@@ -0,0 +1,14 @@
|
||||
#! gmake
|
||||
|
||||
DEPTH = ../..
|
||||
topsrcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
srcdir = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
DIRS = include src
|
||||
|
||||
INCLUDE += -I$(topsrcdir)/modules/libimg/public
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
BIN
mozilla/modules/rdf/images/channels.gif
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
mozilla/modules/rdf/images/file.gif
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
mozilla/modules/rdf/images/guide.gif
Normal file
|
After Width: | Height: | Size: 1017 B |
BIN
mozilla/modules/rdf/images/history.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
mozilla/modules/rdf/images/ldap.gif
Normal file
|
After Width: | Height: | Size: 1017 B |
BIN
mozilla/modules/rdf/images/personal.gif
Normal file
|
After Width: | Height: | Size: 126 B |
BIN
mozilla/modules/rdf/images/search.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
BIN
mozilla/modules/rdf/images/sitemap.gif
Normal file
|
After Width: | Height: | Size: 1.0 KiB |
8
mozilla/modules/rdf/include/MANIFEST
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
rdf.h
|
||||
vocab.h
|
||||
htrdf.h
|
||||
jsec2rdf.h
|
||||
26
mozilla/modules/rdf/include/Makefile
Normal file
@@ -0,0 +1,26 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
MODULE = rdf
|
||||
DEPTH = ../../..
|
||||
EXPORTS = rdf.h htrdf.h vocab.h jsec2rdf.h
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
33
mozilla/modules/rdf/include/Makefile.in
Normal file
@@ -0,0 +1,33 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
MODULE = rdf
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
EXPORTS = rdf.h htrdf.h vocab.h jsec2rdf.h
|
||||
|
||||
EXPORTS := $(addprefix $(srcdir)/, $(EXPORTS))
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
8
mozilla/modules/rdf/include/export.mac
Normal file
@@ -0,0 +1,8 @@
|
||||
#
|
||||
# This is a list of local files which get copied to the mozilla:dist directory
|
||||
#
|
||||
|
||||
rdf.h
|
||||
vocab.h
|
||||
htrdf.h
|
||||
jsec2rdf.h
|
||||
580
mozilla/modules/rdf/include/htrdf.h
Normal file
@@ -0,0 +1,580 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef htrdf_h___
|
||||
#define htrdf_h___
|
||||
|
||||
/* the RDF HT API */
|
||||
|
||||
#include "rdf.h"
|
||||
|
||||
#ifdef XPCOM_XXX
|
||||
#include "ntypes.h"
|
||||
#include "structs.h"
|
||||
#include "pa_parse.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Hyper Tree Api
|
||||
*
|
||||
* Hyper tree is the tree view of the rdf store. This is for use by the FE in
|
||||
* implementing the nav center.
|
||||
*
|
||||
* The RDF structure could be a gnarly graph whose nodes are RDF_Resource.
|
||||
* There can be multiple tree views (HT_View) into this graph. Corresponding
|
||||
* to each view, there is a hyper tree whose nodes are HT_Resource.
|
||||
* Each HT_Resource belongs to exactly one HT_View.
|
||||
* The FE iterate over the hypertree to draw it. It can start the iteration
|
||||
* either at the top or at some interior node. When some state change occurs
|
||||
* in the hypertree, the FE will get notified about the node on which the
|
||||
* change took place. At that point, it can either redraw the whole thing
|
||||
* or do a partial redraw. The FE does this by iterating over the relevant
|
||||
* portions of the hypertree. Since the hypertree is a strict tree, the FE
|
||||
* can also iterate upwards.
|
||||
*
|
||||
*
|
||||
* Possible state changes to the hypertree of an HT_View include :
|
||||
* (i) addition/deletion of nodes
|
||||
* (ii) containers closing/opening
|
||||
* (iii) selection changes
|
||||
* These changes could occur either because of
|
||||
* (i) User clicking around the tree
|
||||
* (ii) Network activity
|
||||
* (iii) scripts running
|
||||
* The FE can recieve notifications about these activities.
|
||||
* If the FE does not want to be notified about something, it can set
|
||||
* the notification mask to block certain notifications.
|
||||
*/
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
/* Opaque data structures */
|
||||
typedef struct _HT_ViewStruct* HT_View;
|
||||
|
||||
typedef struct _HT_PaneStruct* HT_Pane;
|
||||
|
||||
typedef struct _HT_CursorStruct* HT_Cursor;
|
||||
|
||||
typedef struct _HT_ResourceStruct* HT_Resource;
|
||||
|
||||
/* for use with HT_GetTemplate */
|
||||
enum TemplateType {
|
||||
ht_template_chrome,
|
||||
ht_template_management,
|
||||
ht_template_navigation
|
||||
};
|
||||
|
||||
/*
|
||||
* This is the Notification structure that gets passed to the HT layer on
|
||||
* creation of the view. This should be allocated/static memory. HT layer
|
||||
* will store a pointer to this structure. On CloseView, a View Closed
|
||||
* event will be generated and the notification function will be called.
|
||||
* At this point, the module using HT can free the memory associated with
|
||||
* the HT_Notification struct.
|
||||
*/
|
||||
|
||||
|
||||
typedef uint32 HT_NotificationMask;
|
||||
typedef uint32 HT_Event;
|
||||
typedef uint32 HT_Error;
|
||||
|
||||
#define HT_NoErr 0
|
||||
#define HT_Err 1
|
||||
|
||||
struct _HT_NotificationStruct;
|
||||
|
||||
typedef void (*HT_NotificationProc)(struct _HT_NotificationStruct*,
|
||||
HT_Resource node, HT_Event whatHappened, void *param, uint32 tokenType);
|
||||
typedef struct _HT_NotificationStruct {
|
||||
HT_NotificationProc notifyProc;
|
||||
void *data;
|
||||
} HT_NotificationStruct;
|
||||
|
||||
|
||||
/*
|
||||
* HT_Notification events and masks
|
||||
*/
|
||||
|
||||
|
||||
typedef HT_NotificationStruct* HT_Notification;
|
||||
|
||||
#define HT_EVENT_NODE_ADDED 0x00000001UL
|
||||
#define HT_EVENT_NODE_DELETED_DATA 0x00000002UL
|
||||
#define HT_EVENT_NODE_DELETED_NODATA 0x00000004UL
|
||||
#define HT_EVENT_NODE_VPROP_CHANGED 0x00000008UL
|
||||
#define HT_EVENT_NODE_SELECTION_CHANGED 0x00000010UL
|
||||
#define HT_EVENT_NODE_OPENCLOSE_CHANGED 0x00000020UL
|
||||
#define HT_EVENT_VIEW_CLOSED 0x00000040UL /* same as HT_EVENT_VIEW_DELETED */
|
||||
#define HT_EVENT_VIEW_DELETED 0x00000040UL /* same as HT_EVENT_VIEW_CLOSED */
|
||||
#define HT_EVENT_VIEW_SELECTED 0x00000080UL
|
||||
#define HT_EVENT_VIEW_ADDED 0x00000100UL
|
||||
#define HT_EVENT_NODE_OPENCLOSE_CHANGING 0x00000200UL
|
||||
#define HT_EVENT_VIEW_SORTING_CHANGED 0x00000400UL
|
||||
#define HT_EVENT_VIEW_REFRESH 0x00000800UL
|
||||
#define HT_EVENT_VIEW_WORKSPACE_REFRESH 0x00001000UL
|
||||
#define HT_EVENT_NODE_EDIT 0x00002000UL
|
||||
#define HT_EVENT_WORKSPACE_EDIT 0x00004000UL
|
||||
#define HT_EVENT_VIEW_HTML_ADD 0x00008000UL
|
||||
#define HT_EVENT_VIEW_HTML_REMOVE 0x00010000UL
|
||||
#define HT_EVENT_NODE_ENABLE 0x00020000UL
|
||||
#define HT_EVENT_NODE_DISABLE 0x00040000UL
|
||||
#define HT_EVENT_NODE_SCROLLTO 0x00080000UL
|
||||
#define HT_EVENT_COLUMN_ADD 0x00100000UL
|
||||
#define HT_EVENT_COLUMN_DELETE 0x00200000UL
|
||||
#define HT_EVENT_COLUMN_SIZETO 0x00400000UL
|
||||
#define HT_EVENT_COLUMN_REORDER 0x00800000UL
|
||||
#define HT_EVENT_COLUMN_SHOW 0x01000000UL
|
||||
#define HT_EVENT_COLUMN_HIDE 0x02000000UL
|
||||
#define HT_EVENT_VIEW_MODECHANGED 0x04000000UL
|
||||
#define HT_EVENT_VIEW_WINDOWTYPE_CHANGED 0x04000000UL
|
||||
|
||||
#define HT_EVENT_NO_NOTIFICATION_MASK 0x00000000UL
|
||||
#define HT_EVENT_DEFAULT_NOTIFICATION_MASK 0xFFFFFFFFUL
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* View/Pane Creation / Destruction / Management */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* Window Types for Panes */
|
||||
#define HT_POPUP_WINDOW 0
|
||||
#define HT_DOCKED_WINDOW 1
|
||||
#define HT_STANDALONE_WINDOW 2
|
||||
#define HT_EMBEDDED_WINDOW 3
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_PaneFromResource(RDF_Resource r, HT_Notification n, PRBool autoFlush, PRBool autoOpen, PRBool useColumns);
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_PaneFromURL(void* context, char* url, char* templateType,
|
||||
HT_Notification n, PRBool autoFlush, int32 param_count,
|
||||
char** param_names, char** param_values);
|
||||
|
||||
/* NewQuickFilePane
|
||||
* Creates a pane consisting of one view. This view has the RDF resource
|
||||
* corresponding to the Quickfile folder as its root.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewQuickFilePane (HT_Notification notify);
|
||||
|
||||
/* NewToolbarPane
|
||||
* Added by Dave
|
||||
* Create a pane consisting of multiple views. Each view corresponds to a single toolbar.
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewToolbarPane (HT_Notification notify);
|
||||
|
||||
/* NewPersonalToolbarPane
|
||||
* Creates a pane consisting of one view. This view has the RDF resource
|
||||
* corresponding to the Personal Toolbar folder as its root.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewPersonalToolbarPane (HT_Notification notify);
|
||||
|
||||
/* HT_NewBreadcrumbPane
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewBreadcrumbPane (HT_Notification notify);
|
||||
|
||||
PR_PUBLIC_API(void) HT_AddToContainer (HT_Resource container, char *url, char *optionalTitle);
|
||||
PR_PUBLIC_API(void) HT_AddBookmark (char *url, char *optionalTitle);
|
||||
|
||||
/* CreateView
|
||||
* Takes an rdf node as the root of the view tree and creates a XP view.
|
||||
* HT_Notification would be to the notifier when there is a state change.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_NewPane (HT_Notification notify);
|
||||
|
||||
/* DeleteView
|
||||
* Destroy a valid view created via CreateView
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_DeleteView (HT_View view);
|
||||
PR_PUBLIC_API(HT_Error) HT_DeletePane (HT_Pane pane);
|
||||
|
||||
/* HT_TopNode
|
||||
* Obtain the top node associated with a view tree
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_TopNode (HT_View view);
|
||||
|
||||
PR_PUBLIC_API(void*) HT_GetViewFEData (HT_View node);
|
||||
PR_PUBLIC_API(void) HT_SetViewFEData (HT_View node, void* data);
|
||||
PR_PUBLIC_API(void*) HT_GetPaneFEData (HT_Pane pane);
|
||||
PR_PUBLIC_API(void) HT_SetPaneFEData (HT_Pane pane, void* data);
|
||||
|
||||
PR_PUBLIC_API(HT_View) HT_GetSelectedView (HT_Pane pane);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectedView (HT_Pane pane, HT_View view);
|
||||
|
||||
#ifdef XPCOM_XXX
|
||||
PR_PUBLIC_API(void) HT_LayoutComplete(MWContext *context, TagList *metaTags, char *url);
|
||||
#endif
|
||||
|
||||
enum _HT_ViewType {
|
||||
HT_VIEW_BOOKMARK=0, HT_VIEW_HISTORY, HT_VIEW_SITEMAP, HT_VIEW_FILES, HT_VIEW_SEARCH
|
||||
} ;
|
||||
typedef enum _HT_ViewType HT_ViewType;
|
||||
|
||||
/*
|
||||
* HT_GetViewType: find a particular view type (returns NULL if not found or unknown)
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetViewType (HT_Pane pane, HT_ViewType viewType);
|
||||
|
||||
|
||||
/*
|
||||
* HT_GetView
|
||||
* Obtain the view tree associated with a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetView (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetPane (HT_View view);
|
||||
|
||||
/*
|
||||
* HT_GetViewData / HT_SetViewData
|
||||
* get/set FE specific data to be associated with a view
|
||||
*/
|
||||
PR_PUBLIC_API(void*) HT_GetNodeFEData (HT_Resource node);
|
||||
PR_PUBLIC_API(void) HT_SetNodeFEData (HT_Resource node, void* data);
|
||||
|
||||
/*
|
||||
* HT_GetNotificationMask / HT_SetNotificationMask
|
||||
* get/set the notification mask associated with a view
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_GetNotificationMask (HT_Pane node, HT_NotificationMask *mask);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNotificationMask (HT_Pane node, HT_NotificationMask mask);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* View Traversal */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetViewName(HT_View view);
|
||||
|
||||
/*
|
||||
* HT_GetNthView
|
||||
*/
|
||||
PR_PUBLIC_API(HT_View) HT_GetNthView (HT_Pane pane, uint32 theIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetViewIndex(HT_View view);
|
||||
PR_PUBLIC_API(uint32) HT_GetViewListCount(HT_Pane pane);
|
||||
|
||||
/*
|
||||
* HT_GetNthItem / HT_GetNodeIndex
|
||||
* get the nth resource in a view (or NULL if not in view),
|
||||
* or find a resource's index in a view
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNthItem (HT_View view, uint32 theIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetNodeIndex(HT_View view, HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetItemListCount(HT_View view);
|
||||
PR_PUBLIC_API(uint16) HT_GetItemIndentation(HT_Resource r);
|
||||
/*
|
||||
* HT_GetParent
|
||||
* obtain the parent of a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetParent (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_NodeDisplayString/HT_ViewDisplayString (obsolete)
|
||||
* obtain the name of a node
|
||||
*/
|
||||
PR_PUBLIC_API(HT_Error) HT_NodeDisplayString (HT_Resource node, char *buffer, int bufferLen); /* obsolete! */
|
||||
PR_PUBLIC_API(HT_Error) HT_ViewDisplayString (HT_View view, char *buffer, int bufferLen); /* obsolete! */
|
||||
|
||||
/* an API for external access to the templates. It takes a specifier
|
||||
defined by enum TemplateType, in this file. HT_GetTemplate() returns
|
||||
the basic HT_Pane corresponding to the requested type. */
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetTemplate(int templateType);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_GetTemplateData(HT_Resource node, void* token, uint32 tokenType, void **nodeData);
|
||||
PR_PUBLIC_API(PRBool) HT_GetNodeData (HT_Resource node, void *token,
|
||||
uint32 tokenType, void **data);
|
||||
PR_PUBLIC_API(PRBool) HT_IsNodeDataEditable(HT_Resource node,
|
||||
void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNodeData (HT_Resource node, void *token,
|
||||
uint32 tokenType, void *data);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetNodeName (HT_Resource node, void *data);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetTreeStateForButton(HT_Resource node, int state);
|
||||
PR_PUBLIC_API(int) HT_GetTreeStateForButton(HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetWindowType(HT_Pane pane, int windowType);
|
||||
PR_PUBLIC_API(int) HT_GetWindowType(HT_Pane pane);
|
||||
|
||||
/*
|
||||
* HT_GetLargeIconURL / HT_GetSmallIconURL
|
||||
* obtain the large/small icon URLs for a node if available, otherwise return NULL
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetWorkspaceLargeIconURL (HT_View view);
|
||||
PR_PUBLIC_API(char *) HT_GetWorkspaceSmallIconURL (HT_View view);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeLargeIconURL (HT_Resource r);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeSmallIconURL (HT_Resource r);
|
||||
PR_PUBLIC_API(char *) HT_GetIconURL(HT_Resource r, PRBool isToolbarIcon, PRBool isWorkspace, int buttonState);
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetLargeIconURL (HT_Resource r); /* obsolete! */
|
||||
PR_PUBLIC_API(char *) HT_GetSmallIconURL (HT_Resource r); /* obsolete! */
|
||||
|
||||
/*
|
||||
* HT_NewColumnCursor / HT_GetNextColumn / HT_DeleteColumnCursor
|
||||
* obtain column information
|
||||
*/
|
||||
|
||||
enum _HT_ColumnType {
|
||||
HT_COLUMN_UNKNOWN=0, HT_COLUMN_STRING, HT_COLUMN_DATE_STRING,
|
||||
HT_COLUMN_DATE_INT, HT_COLUMN_INT, HT_COLUMN_RESOURCE
|
||||
} ;
|
||||
typedef enum _HT_ColumnType HT_ColumnType;
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewColumnCursor (HT_View view);
|
||||
PR_PUBLIC_API(PRBool) HT_GetNextColumn(HT_Cursor cursor, char **colName,
|
||||
uint32 *colWidth, void **token, uint32 *tokenType);
|
||||
PR_PUBLIC_API(void) HT_DeleteColumnCursor(HT_Cursor cursor);
|
||||
PR_PUBLIC_API(void) HT_SetColumnOrder(HT_View view, void *srcColToken,
|
||||
void *destColToken,
|
||||
PRBool afterDestFlag);
|
||||
PR_PUBLIC_API(void) HT_SetSortColumn(HT_View view, void *token,
|
||||
uint32 tokenType, PRBool descendingFlag);
|
||||
PR_PUBLIC_API(void) HT_SetColumnWidth(HT_View view, void *token,
|
||||
uint32 tokenType, uint32 width);
|
||||
PR_PUBLIC_API(uint32) HT_GetColumnWidth(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_SetColumnVisibility(HT_View view, void *token, uint32 tokenType, PRBool isHiddenFlag);
|
||||
PR_PUBLIC_API(PRBool) HT_GetColumnVisibility(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_ShowColumn(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(void) HT_HideColumn(HT_View view, void *token, uint32 tokenType);
|
||||
PR_PUBLIC_API(PRBool) HT_ContainerSupportsNaturalOrderSort(HT_Resource container);
|
||||
PR_PUBLIC_API(void) HT_SetColumnFEData(HT_View view, void *token, void *data);
|
||||
PR_PUBLIC_API(void *) HT_GetColumnFEData (HT_View view, void *token);
|
||||
|
||||
PR_PUBLIC_API(void) HT_SetTopVisibleNodeIndex(HT_View view, uint32 topNodeIndex);
|
||||
PR_PUBLIC_API(uint32) HT_GetTopVisibleNodeIndex(HT_View view);
|
||||
|
||||
|
||||
/*
|
||||
* HT Menu Commands
|
||||
*/
|
||||
|
||||
enum _HT_MenuCmd {
|
||||
HT_CMD_SEPARATOR=0, HT_CMD_OPEN, HT_CMD_OPEN_FILE, HT_CMD_PRINT_FILE,
|
||||
HT_CMD_OPEN_NEW_WIN, HT_CMD_OPEN_COMPOSER, HT_CMD_OPEN_AS_WORKSPACE,
|
||||
HT_CMD_NEW_BOOKMARK, HT_CMD_NEW_FOLDER, HT_CMD_NEW_SEPARATOR,
|
||||
HT_CMD_MAKE_ALIAS, HT_CMD_ADD_TO_BOOKMARKS, HT_CMD_SAVE_AS,
|
||||
HT_CMD_CREATE_SHORTCUT, HT_CMD_SET_TOOLBAR_FOLDER,
|
||||
HT_CMD_SET_BOOKMARK_MENU, HT_CMD_SET_BOOKMARK_FOLDER, HT_CMD_CUT,
|
||||
HT_CMD_COPY, HT_CMD_PASTE, HT_CMD_DELETE_FILE, HT_CMD_DELETE_FOLDER,
|
||||
HT_CMD_REVEAL_FILEFOLDER, HT_CMD_PROPERTIES, HT_CMD_RENAME_WORKSPACE,
|
||||
HT_CMD_DELETE_WORKSPACE, HT_CMD_MOVE_WORKSPACE_UP, HT_CMD_MOVE_WORKSPACE_DOWN,
|
||||
HT_CMD_REFRESH, HT_CMD_EXPORT, HT_CMD_REMOVE_BOOKMARK_MENU,
|
||||
HT_CMD_REMOVE_BOOKMARK_FOLDER, HT_CMD_SET_PASSWORD, HT_CMD_REMOVE_PASSWORD,
|
||||
HT_CMD_EXPORTALL, HT_CMD_UNDO, HT_CMD_NEW_WORKSPACE, HT_CMD_RENAME, HT_CMD_FIND,
|
||||
HT_CMD_GET_NEW_MAIL
|
||||
};
|
||||
|
||||
typedef enum _HT_MenuCmd HT_MenuCmd;
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewContextMenuCursor(HT_Resource r);
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewContextualMenuCursor (HT_View view,
|
||||
PRBool workspaceMenuCmds,
|
||||
PRBool backgroundMenuCmds);
|
||||
PR_PUBLIC_API(PRBool) HT_NextContextMenuItem(HT_Cursor c, HT_MenuCmd *menuCmd);
|
||||
PR_PUBLIC_API(void) HT_DeleteContextMenuCursor(HT_Cursor c);
|
||||
PR_PUBLIC_API(char *) HT_GetMenuCmdName(HT_MenuCmd menuCmd);
|
||||
PR_PUBLIC_API(HT_Error) HT_DoMenuCmd(HT_Pane pane, HT_MenuCmd menuCmd);
|
||||
PR_PUBLIC_API(PRBool) HT_IsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd);
|
||||
|
||||
/*
|
||||
* HT_Find
|
||||
* show HTML find dialog (hint is the default string to look for and can be NULL)
|
||||
*/
|
||||
PR_PUBLIC_API(void) HT_Find(char *hint);
|
||||
|
||||
/*
|
||||
* HT_Properties
|
||||
* show HTML dialog of node's properties
|
||||
*/
|
||||
PR_PUBLIC_API(void) HT_Properties (HT_Resource r);
|
||||
|
||||
|
||||
/*
|
||||
* HT_GetRDFResource
|
||||
* obtain the RDF_Resource associated with a HT node
|
||||
*/
|
||||
PR_PUBLIC_API(RDF_Resource) HT_GetRDFResource (HT_Resource node);
|
||||
|
||||
/*
|
||||
* Access the node's name and URL
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(char *) HT_GetNodeURL(HT_Resource node);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeDisplayURL(HT_Resource node);
|
||||
PR_PUBLIC_API(char *) HT_GetNodeName(HT_Resource node);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Accessor and Mutators */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* HT_IsURLBar
|
||||
* determine whether node is a URL bar
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsURLBar (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_IsSeparator
|
||||
* determine whether node is a separator
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsSeparator (HT_Resource node);
|
||||
|
||||
/*
|
||||
* HT_IsContainer
|
||||
* determine whether node is a container
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsContainer (HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetCountVisibleChildren(HT_Resource node);
|
||||
PR_PUBLIC_API(uint32) HT_GetCountDirectChildren(HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetContainerItem(HT_Resource parent, uint32 childNum);
|
||||
|
||||
/*
|
||||
* HT_DataSource : obtain the origin of the data
|
||||
* HT_IsLocalData : is the data local?
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_IsLocalData (HT_Resource node) ;
|
||||
PR_PUBLIC_API(char *) HT_DataSource (HT_Resource node) ;
|
||||
|
||||
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetHTPaneList ();
|
||||
PR_PUBLIC_API(HT_Pane) HT_GetNextHTPane (HT_Pane pane);
|
||||
/*
|
||||
* HT_IsSelected / HT_GetSelectedState / HT_SetSelectedState
|
||||
* manage selection state of a node; get/set operations will generate
|
||||
* a HT_EVENT_NODE_SELECTION_CHANGED notification unless masked out
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsSelected (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetSelectedState (HT_Resource node, PRBool *selectedState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectedState (HT_Resource node, PRBool isSelected);
|
||||
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelection (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectionAll (HT_View view, PRBool selectedState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetSelectionRange (HT_Resource node1, HT_Resource node2);
|
||||
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNextSelection(HT_View view, HT_Resource startingNode);
|
||||
PR_PUBLIC_API(void) HT_ToggleSelection(HT_Resource node);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_IsEnabled (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetEnabledState (HT_Resource node, PRBool *enabledState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetEnabledState(HT_Resource node, PRBool isEnabled);
|
||||
|
||||
#ifdef XPCOM_XXX /* mwcontext dependency */
|
||||
PR_PUBLIC_API(PRBool) HT_Launch(HT_Resource node, MWContext *context);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_LaunchURL(HT_Pane pane, char *url, MWContext *context);
|
||||
#endif
|
||||
|
||||
PR_PUBLIC_API(void) HT_TypeTo(HT_Pane pane, char *typed);
|
||||
|
||||
/*
|
||||
* HT_NewCursor, HT_GetNextItem, HT_DeleteCursor
|
||||
* Used to iterate over a container's children. Until the container has been
|
||||
* opened at least once, you won't see any of the children.
|
||||
*/
|
||||
|
||||
PR_PUBLIC_API(HT_Cursor) HT_NewCursor (HT_Resource node) ;
|
||||
PR_PUBLIC_API(HT_Error) HT_DeleteCursor (HT_Cursor cursor) ;
|
||||
PR_PUBLIC_API(HT_Resource) HT_GetNextItem (HT_Cursor cursor) ;
|
||||
|
||||
/*
|
||||
* HT_IsContainerOpen / HT_GetOpenState / HT_SetOpenState
|
||||
* manage open state of a node; get/set operations will generate
|
||||
* a HT_EVENT_NODE_OPENCLOSE_CHANGED notification unless masked out
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_IsContainerOpen (HT_Resource node);
|
||||
PR_PUBLIC_API(HT_Error) HT_GetOpenState (HT_Resource containerNode, PRBool *openState);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetOpenState (HT_Resource containerNode, PRBool isOpen);
|
||||
PR_PUBLIC_API(HT_Error) HT_SetAutoFlushOpenState (HT_Resource containerNode, PRBool isOpen);
|
||||
|
||||
|
||||
/*
|
||||
* HT_ItemHasForwardSibling / HT_ItemHasBackwardSibling
|
||||
* determine if a given node has a following/previous sibling node
|
||||
*/
|
||||
PR_PUBLIC_API(PRBool) HT_ItemHasForwardSibling(HT_Resource r);
|
||||
PR_PUBLIC_API(PRBool) HT_ItemHasBackwardSibling(HT_Resource r);
|
||||
|
||||
PR_PUBLIC_API(void) HT_NewWorkspace(HT_Pane pane, char *id, char *optionalTitle);
|
||||
PR_PUBLIC_API(void) HT_SetWorkspaceOrder(HT_View src, HT_View dest, PRBool afterDestFlag);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Creating new containers */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(HT_Resource) HT_MakeNewContainer(HT_Resource parent, char* name);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Drag and Drop */
|
||||
/* drop actions should be made an enum */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
typedef uint8 HT_DropAction;
|
||||
|
||||
|
||||
#define DROP_NOT_ALLOWED 0
|
||||
#define COPY_MOVE_CONTENT 1
|
||||
#define UPLOAD_RDF 2
|
||||
#define COPY_MOVE_LINK 3
|
||||
#define UPLOAD_LFS 4
|
||||
#define DROP_ABORTED 5
|
||||
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropHTROn(HT_Resource dropTarget, HT_Resource obj);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropURLOn(HT_Resource dropTarget, char* url);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropHTROn(HT_Resource dropTarget, HT_Resource obj);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLOn(HT_Resource dropTarget, char* url);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAndTitleOn(HT_Resource dropTarget,
|
||||
char* url, char *title);
|
||||
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropHTRAtPos(HT_Resource dropTarget, HT_Resource obj,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_CanDropURLAtPos(HT_Resource dropTarget, char* url,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropHTRAtPos(HT_Resource dropTarget, HT_Resource obj,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAtPos(HT_Resource dropTarget, char* url,
|
||||
PRBool before);
|
||||
PR_PUBLIC_API(HT_DropAction) HT_DropURLAndTitleAtPos(HT_Resource dropTarget,
|
||||
char* url, char *title, PRBool before);
|
||||
PR_PUBLIC_API(PRBool) HT_IsDropTarget(HT_Resource dropTarget);
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Editing */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_RemoveChild (HT_Resource parent, HT_Resource child);
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
/* Other */
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
|
||||
PR_PUBLIC_API(RDF) RDF_GetNavCenterDB();
|
||||
PR_PUBLIC_API(void) HT_InformRDFOfNewDocument(char* address);
|
||||
|
||||
PR_PUBLIC_API(PRBool) HT_HasHTMLPane(HT_View htView);
|
||||
PR_PUBLIC_API(char *) HT_HTMLPaneHeight(HT_View htView);
|
||||
|
||||
PR_PUBLIC_API(void) HT_AddSitemapFor(HT_Pane htPane, char *pUrl, char *pSitemapUrl, char* name);
|
||||
PR_PUBLIC_API(void) HT_AddRelatedLinksFor(HT_Pane htPane, char *pUrl);
|
||||
PR_PUBLIC_API(void) HT_ExitPage(HT_Pane htPane, char *pUrl);
|
||||
PR_PUBLIC_API(void)
|
||||
RDF_AddCookieResource(char* name, char* path, char* host, char* expires, char* value,
|
||||
PRBool isDomain, PRBool secure) ;
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* htrdf_h___ */
|
||||
75
mozilla/modules/rdf/include/jsec2rdf.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _JSEC_2_RDF_H_
|
||||
#define _JSEC_2_RDF_H_
|
||||
|
||||
#include "rdf.h"
|
||||
|
||||
typedef int16 JSec_Error;
|
||||
|
||||
#define JSec_OK ((JSec_Error)0x0000)
|
||||
#define JSec_NullObject ((JSec_Error)0x0001)
|
||||
|
||||
typedef RDF_Resource JSec_Principal;
|
||||
typedef RDF_Resource JSec_PrincipalUse;
|
||||
typedef RDF_Resource JSec_Target;
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
PR_EXTERN(char*) RDFJSec_GetPrincipalURLString(char *principalID);
|
||||
PR_EXTERN(const char*) RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_InitPrivilegeDB(); /* just use gNCDB */
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SavePrivilegeDB();
|
||||
PR_EXTERN(JSec_Error) RDFJSec_ClosePrivilegeDB();
|
||||
|
||||
PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipals();
|
||||
PR_EXTERN(JSec_Principal) RDFJSec_NextPrincipal(RDF_Cursor c);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_ReleaseCursor(RDF_Cursor c);
|
||||
|
||||
PR_EXTERN(JSec_Principal) RDFJSec_NewPrincipal(char* principalID);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipal(JSec_Principal pr);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipal(JSec_Principal pr);
|
||||
PR_EXTERN(char*) RDFJSec_PrincipalID(JSec_Principal pr);
|
||||
PR_EXTERN(void*) RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue);
|
||||
|
||||
PR_EXTERN(RDF_Cursor) RDFJSec_ListAllPrincipalUses(JSec_Principal pr);
|
||||
PR_EXTERN(JSec_PrincipalUse) RDFJSec_NextPrincipalUse(RDF_Cursor c);
|
||||
|
||||
PR_EXTERN(JSec_PrincipalUse) RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv);
|
||||
PR_EXTERN(char*) RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse p);
|
||||
|
||||
PR_EXTERN(JSec_Error) RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr);
|
||||
PR_EXTERN(JSec_Target) RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse p);
|
||||
|
||||
PR_EXTERN(JSec_Target) RDFJSec_NewTarget(char* targetName, JSec_Principal pr);
|
||||
PR_EXTERN(char*) RDFJSec_GetTargetName(JSec_Target tr);
|
||||
PR_EXTERN(char*) RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType);
|
||||
PR_EXTERN(JSec_Error) RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* _JSEC_2_RDF_H_ */
|
||||
37
mozilla/modules/rdf/include/makefile.win
Normal file
@@ -0,0 +1,37 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
|
||||
|
||||
MODULE = rdf
|
||||
|
||||
DEPTH = ..\..\..
|
||||
|
||||
EXPORTS = rdf.h \
|
||||
rdfc.h \
|
||||
nsIRDFService.h \
|
||||
nsIRDFDataSource.h \
|
||||
nsIRDFDataBase.h \
|
||||
nsIRDFObserver.h \
|
||||
nsIRDFCursor.h \
|
||||
htrdf.h \
|
||||
vocab.h \
|
||||
jsec2rdf.h \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)/config/rules.mak>
|
||||
|
||||
53
mozilla/modules/rdf/include/nsIRDFCursor.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFCursor_h__
|
||||
#define nsIRDFCursor_h__
|
||||
|
||||
/*
|
||||
|
||||
nsIRDFCursor:
|
||||
|
||||
An iterator for RDF data sources.
|
||||
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 1c2abdb0-4cef-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFCURSOR_IID \
|
||||
{ \
|
||||
0x1c2abdb0, \
|
||||
0x4cef, \
|
||||
0x11d2, \
|
||||
{ 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFCursor : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD HasElements(PRBool& hasElements) = 0;
|
||||
|
||||
NS_IMETHOD Next(RDF_NodeStruct& next /* in/out */) = 0;
|
||||
|
||||
};
|
||||
|
||||
#endif /* nsIRDFCursor_h__ */
|
||||
74
mozilla/modules/rdf/include/nsIRDFDataBase.h
Normal file
@@ -0,0 +1,74 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataBase_h__
|
||||
#define nsIRDFDataBase_h__
|
||||
|
||||
/*
|
||||
This file contains the interface definition for an RDF database.
|
||||
|
||||
RDF databases aggregate RDF data sources (see nsIRDFDataSource.h)
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 96343820-307c-11d2-bc15-00805f912fe7
|
||||
#define NS_IRDFDATABASE_IID \
|
||||
{ \
|
||||
0x96343820, \
|
||||
0x307c, \
|
||||
0x11d2, \
|
||||
{ 0xb, 0xc15, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFDataBase : public nsIRDFDataSource {
|
||||
public:
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
NS_IMETHOD Initialize(nsIRDFResourceManager* r) = 0;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/*
|
||||
Add a data source for the specified URL to the database.
|
||||
|
||||
Parameters:
|
||||
dataSource -- a ptr to the data source to add
|
||||
|
||||
Returns:
|
||||
*/
|
||||
NS_IMETHOD AddDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
NS_IMETHOD RemoveDataSource(nsIRDFDataSource* dataSource) = 0;
|
||||
|
||||
NS_IMETHOD GetDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */ ) = 0;
|
||||
#endif
|
||||
|
||||
// XXX move these to datasource?
|
||||
NS_IMETHOD DeleteAllArcs(RDF_Resource resource) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFDataBase_h__ */
|
||||
223
mozilla/modules/rdf/include/nsIRDFDataSource.h
Normal file
@@ -0,0 +1,223 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFDataSource_h__
|
||||
#define nsIRDFDataSource_h__
|
||||
|
||||
/*
|
||||
This file contains the interface definition for an RDF data source.
|
||||
|
||||
Classes which implement this interface for a particular type of URL
|
||||
are registered with the RDF singleton via nsIRDF::RegisterHandler(...)
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
// 852666b0-2cce-11d2-bc14-00805f912fe7
|
||||
#define NS_IRDFDATASOURCE_IID \
|
||||
{ \
|
||||
0x852666b0, \
|
||||
0x2cce, \
|
||||
0x11d2, \
|
||||
{ 0xb, 0xc14,0x00, 0x80, 0x5f, 0x91 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
class nsIRDFCursor;
|
||||
class nsIRDFObserver;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
class nsIRDFDataSource : public nsISupports {
|
||||
public:
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Initialize this data source
|
||||
*/
|
||||
NS_IMETHOD Initialize(RDF_String url,
|
||||
nsIRDFResourceManager* m);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get the name of this data source.
|
||||
*
|
||||
* For regular data sources, this will be the URL of the source.
|
||||
*
|
||||
* For aggregated sources, it generally will not be a valid RDF URL.
|
||||
*/
|
||||
NS_IMETHOD GetName(const RDF_String* name /* out */ ) = 0;
|
||||
|
||||
/**
|
||||
* Find an RDF resource that points to a given node over the
|
||||
* specified arc & truth value (defaults to "PR_TRUE").
|
||||
*/
|
||||
NS_IMETHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all RDF resources that point to a given node over the
|
||||
* specified arc & truth value (defaults to "PR_TRUE").
|
||||
*/
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find a child of that is related to the source by the given arc
|
||||
* arc and truth value (defaults to PR_TRUE).
|
||||
*/
|
||||
NS_IMETHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */) = 0;
|
||||
|
||||
NS_IMETHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all children of that are related to the source by the given arc
|
||||
* arc and truth value (defaults to PR_TRUE).
|
||||
*/
|
||||
NS_IMETHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */) = 0;
|
||||
|
||||
NS_IMETHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */) = 0;
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Find all parents that point to a node over a given arc label,
|
||||
* regardless of truth value.
|
||||
*/
|
||||
NS_IMETHOD GetAllSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor2 **sources /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Find all children of a resource that are related by the
|
||||
* given arc label, regardless of the truth value.
|
||||
*/
|
||||
NS_IMETHOD GetAllTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor2 **targets /* out */);
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
|
||||
/**
|
||||
* Add an assertion to the graph.
|
||||
*/
|
||||
NS_IMETHOD Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv = PR_TRUE) = 0;
|
||||
|
||||
/**
|
||||
* Remove an assertion from the graph.
|
||||
*/
|
||||
NS_IMETHOD Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target) = 0;
|
||||
|
||||
/**
|
||||
* Query whether an assertion exists in this graph.
|
||||
*
|
||||
*/
|
||||
NS_IMETHOD HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool truthValue,
|
||||
PRBool* hasAssertion /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Add an observer to this data source.
|
||||
*/
|
||||
NS_IMETHOD AddObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask type = RDF_ANY_NOTIFY) = 0;
|
||||
|
||||
/**
|
||||
* Remove an observer from this data source
|
||||
*/
|
||||
NS_IMETHOD RemoveObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask = RDF_ANY_NOTIFY) = 0;
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that point into a node.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */) = 0;
|
||||
|
||||
/**
|
||||
* Get a cursor to iterate over all the arcs that originate in
|
||||
* a resource.
|
||||
*/
|
||||
NS_IMETHOD ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */) = 0;
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
/**
|
||||
* Notify this data source that it is a child of a database.
|
||||
*
|
||||
* The datasource must send notifications to the parent when
|
||||
* changes to it's graph are made, in case the parent has observers
|
||||
* interested in the events generated.
|
||||
*/
|
||||
NS_IMETHOD AddParent(nsIRDFDataBase* parent) = 0;
|
||||
|
||||
/**
|
||||
* Notify this data source that it has been disconnected from a
|
||||
* parent.
|
||||
*/
|
||||
NS_IMETHOD RemoveParent(nsIRDFDataBase* parent) = 0;
|
||||
|
||||
/**
|
||||
* Request that a data source obtain updates if applicable.
|
||||
*/
|
||||
// XXX move this to an nsIRDFRemoteDataStore interface?
|
||||
NS_IMETHOD Update(RDF_Resource hint) = 0;
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
/**
|
||||
* Request that a data source write it's contents out to
|
||||
* permanent storage if applicable.
|
||||
*/
|
||||
NS_IMETHOD Flush() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFDataSource_h__ */
|
||||
51
mozilla/modules/rdf/include/nsIRDFObserver.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFObserver_h__
|
||||
#define nsIRDFObserver_h__
|
||||
|
||||
/*
|
||||
This file defines the interface for RDF observers.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "rdf.h"
|
||||
|
||||
|
||||
// 3cc75360-484a-11d2-bc16-00805f912fe7
|
||||
#define NS_IRDFOBSERVER_IID \
|
||||
{ \
|
||||
0x3cc75360, \
|
||||
0x484a, \
|
||||
0x11d2, \
|
||||
{ 0xbc, 0x16, 0x00, 0x80, 0x5f, 0x91, 0x2f, 0xe7 } \
|
||||
}
|
||||
|
||||
class nsIRDFDataSource;
|
||||
|
||||
class nsIRDFObserver : public nsISupports
|
||||
{
|
||||
public:
|
||||
|
||||
NS_IMETHOD HandleEvent(nsIRDFDataSource *source,
|
||||
RDF_Event event) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFObserver_h__ */
|
||||
68
mozilla/modules/rdf/include/nsIRDFService.h
Normal file
@@ -0,0 +1,68 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef nsIRDFService_h__
|
||||
#define nsIRDFService_h__
|
||||
|
||||
/*
|
||||
This file defines the interface for the RDF singleton,
|
||||
which maintains various pieces of pieces of information global
|
||||
to all RDF data sources.
|
||||
|
||||
In particular, it provides the interface for mapping rdf URL types
|
||||
to nsIRDFDataSource implementors for that type of content.
|
||||
*/
|
||||
|
||||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h" /* nsCID typedef, for consistency */
|
||||
#include "rdf.h"
|
||||
|
||||
class nsIRDFDataSource;
|
||||
class nsIRDFDataBase;
|
||||
|
||||
// 6edf3660-32f0-11d2-9abe-00600866748f
|
||||
#define NS_IRDFSERVICE_IID \
|
||||
{ \
|
||||
0x6edf3660, \
|
||||
0x32f0, \
|
||||
0x11d2, \
|
||||
{ 0x9a, 0xbe, 0x00, 0x60, 0x08, 0x66, 0x74, 0x8f } \
|
||||
}
|
||||
|
||||
|
||||
class nsIRDFService : public nsISupports {
|
||||
public:
|
||||
|
||||
NS_IMETHOD Initialize();
|
||||
|
||||
#ifdef RDF_NOT_IMPLEMENTED
|
||||
NS_IMETHOD RegisterHandler(RDF_String url_selector, const nsCID& clsid) = 0;
|
||||
|
||||
NS_IMETHOD RemoveHandler(RDF_String url_selector, const nsCID& clsid) = 0;
|
||||
|
||||
NS_IMETHOD CreateDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */) = 0;
|
||||
#endif /* RDF_NOT_IMPLEMENTED */
|
||||
|
||||
NS_IMETHOD CreateDatabase(const RDF_String* url_ary,
|
||||
nsIRDFDataBase **db /* out */) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif /* nsIRDFService_h__ */
|
||||
120
mozilla/modules/rdf/include/rdf.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef rdf_h___
|
||||
#define rdf_h___
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
|
||||
typedef nsresult RDF_Error;
|
||||
|
||||
#define RDF_ERROR_ILLEGAL_ASSERT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,1)
|
||||
#define RDF_ERROR_ILLEGAL_KILL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,2)
|
||||
#define RDF_ERROR_UNABLE_TO_CREATE NS_ERROR_GENERATE_FAILURE( NS_ERROR_MODULE_RDF,3)
|
||||
|
||||
#define RDF_ERROR_NO_MEMORY NS_ERROR_OUT_OF_MEMORY /* XXX remove this */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct RDF_ResourceStruct* RDF_Resource;
|
||||
typedef struct RDF_CursorStruct* RDF_Cursor;
|
||||
typedef struct RDF_DBStruct* RDF;
|
||||
typedef struct RDF_TranslatorStruct *RDFT;
|
||||
|
||||
typedef char* RDF_String;
|
||||
|
||||
typedef enum {
|
||||
RDF_ANY_TYPE,
|
||||
RDF_RESOURCE_TYPE,
|
||||
RDF_INT_TYPE,
|
||||
RDF_STRING_TYPE,
|
||||
#ifdef RDF_BLOB
|
||||
RDF_BLOB_TYPE
|
||||
#endif
|
||||
} RDF_ValueType;
|
||||
|
||||
|
||||
#ifdef RDF_BLOB
|
||||
typedef struct RDF_BlobStruct {
|
||||
PRUint32 size;
|
||||
void* data;
|
||||
} *RDF_Blob;
|
||||
#endif
|
||||
|
||||
typedef struct RDF_NodeStruct {
|
||||
RDF_ValueType type;
|
||||
union {
|
||||
RDF_Resource r;
|
||||
RDF_String s;
|
||||
#ifdef RDF_BLOB
|
||||
RDF_Blob b;
|
||||
#endif
|
||||
} value;
|
||||
} *RDF_Node;
|
||||
|
||||
typedef PRUint32 RDF_EventType;
|
||||
#define RDF_ASSERT_NOTIFY ((RDF_EventType)0x00000001)
|
||||
#define RDF_DELETE_NOTIFY ((RDF_EventType)0x00000002)
|
||||
#define RDF_KILL_NOTIFY ((RDF_EventType)0x00000004)
|
||||
#define RDF_CREATE_NOTIFY ((RDF_EventType)0x00000008)
|
||||
#define RDF_RESOURCE_GC_NOTIFY ((RDF_EventType)0x00000010)
|
||||
#define RDF_INSERT_NOTIFY ((RDF_EventType)0x00000020)
|
||||
|
||||
typedef PRUint32 RDF_EventMask;
|
||||
#define RDF_ANY_NOTIFY ((RDF_EventMask)0xFFFFFFFF)
|
||||
|
||||
typedef struct RDF_AssertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* v;
|
||||
RDF_ValueType type;
|
||||
PRBool tv;
|
||||
char* dataSource;
|
||||
} *RDF_AssertEvent;
|
||||
|
||||
|
||||
typedef struct RDF_UnassertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
void* v;
|
||||
RDF_ValueType type;
|
||||
char* dataSource;
|
||||
} *RDF_UnassertEvent;
|
||||
|
||||
typedef struct RDF_KillEventStruct {
|
||||
RDF_Resource u;
|
||||
} *RDF_KillEvent;
|
||||
|
||||
|
||||
typedef struct RDF_EventStruct {
|
||||
RDF_EventType eventType;
|
||||
union ev {
|
||||
struct RDF_AssertEventStruct assert;
|
||||
struct RDF_UnassertEventStruct unassert;
|
||||
struct RDF_KillEventStruct kill;
|
||||
} event;
|
||||
} *RDF_Event;
|
||||
|
||||
#include "vocab.h"
|
||||
#include "rdfc.h"
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
106
mozilla/modules/rdf/include/rdf2.h
Normal file
@@ -0,0 +1,106 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef rdf_h___
|
||||
#define rdf_h___
|
||||
|
||||
#include "nspr.h"
|
||||
#include "nsError.h"
|
||||
|
||||
typedef nsresult RDF_Error;
|
||||
|
||||
#define RDF_ERROR_ILLEGAL_ASSERT NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,1)
|
||||
#define RDF_ERROR_ILLEGAL_KILL NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_RDF,2)
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct RDF_ResourceStruct* RDF_Resource;
|
||||
typedef struct RDF_CursorStruct* RDF_Cursor;
|
||||
typedef struct RDF_DBStruct* RDF;
|
||||
typedef struct RDF_TranslatorStruct *RDFT;
|
||||
|
||||
typedef enum {
|
||||
RDF_ANY_TYPE,
|
||||
RDF_RESOURCE_TYPE,
|
||||
RDF_INT_TYPE,
|
||||
RDF_STRING_TYPE.
|
||||
#ifdef RDF_BLOB
|
||||
RDF_BLOB_TYPE
|
||||
#endif
|
||||
} RDF_ValueType;
|
||||
|
||||
|
||||
#ifdef RDF_BLOB
|
||||
typedef struct RDF_BlobStruct {
|
||||
PRUint32 size;
|
||||
void* data;
|
||||
} *RDF_Blob;
|
||||
#endif
|
||||
|
||||
typedef struct RDF_NodeStruct {
|
||||
RDF_ValueType type;
|
||||
union {
|
||||
RDF_Resource r;
|
||||
RDF_String s;
|
||||
#ifdef RDF_BLOB
|
||||
RDF_Blob b;
|
||||
#endif
|
||||
} value;
|
||||
} *RDF_Node;
|
||||
|
||||
typedef PRUint32 RDF_EventType;
|
||||
#define RDF_ASSERT_NOTIFY ((RDF_EventType)0x00000001)
|
||||
#define RDF_DELETE_NOTIFY ((RDF_EventType)0x00000002)
|
||||
|
||||
typedef PRUint32 RDF_EventMask;
|
||||
#define RDF_ANY_NOTIFY ((RDF_EventMask)0xFFFFFFFF)
|
||||
|
||||
typedef struct RDF_AssertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
struct RDF_NodeStruct v;
|
||||
PRBool tv;
|
||||
char* dataSource;
|
||||
} *RDF_AssertEvent;
|
||||
|
||||
typedef struct RDF_UnassertEventStruct {
|
||||
RDF_Resource u;
|
||||
RDF_Resource s;
|
||||
struct RDF_NodeStruct v;
|
||||
char* dataSource;
|
||||
} *RDF_UnassertEvent;
|
||||
|
||||
typedef struct RDF_KillEventStruct {
|
||||
RDF_Resource u;
|
||||
} *RDF_KillEvent;
|
||||
|
||||
typedef struct RDF_EventStruct {
|
||||
RDF_EventType eventType;
|
||||
union ev {
|
||||
struct RDF_AssertEventStruct assert;
|
||||
struct RDF_UnassertEventStruct unassert;
|
||||
struct RDF_KillEventStruct kill;
|
||||
} event;
|
||||
} *RDF_Event;
|
||||
|
||||
#include "vocab.h"
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdf_h___ */
|
||||
128
mozilla/modules/rdf/include/rdfc.h
Normal file
@@ -0,0 +1,128 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef rdfc_h__
|
||||
#define rdfc_h__
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nspr.h"
|
||||
|
||||
/* core rdf apis */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
typedef struct _RDF_InitParamsStruct {
|
||||
char *profileURL;
|
||||
char *bookmarksURL;
|
||||
char *globalHistoryURL;
|
||||
} RDF_InitParamsStruct;
|
||||
|
||||
typedef struct _RDF_InitParamsStruct* RDF_InitParams;
|
||||
|
||||
struct RDF_NotificationStruct;
|
||||
typedef struct RDF_NotificationStruct* RDF_Notification;
|
||||
|
||||
typedef void (*RDF_NotificationProc)(RDF_Event theEvent, void* pdata);
|
||||
|
||||
PR_PUBLIC_API(RDF) RDF_GetDB(const RDF_String* dbs);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDB(RDF rdf);
|
||||
PR_PUBLIC_API(RDFT) RDF_AddDataSource(RDF rdf, char* dataSource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseDataSource(RDF rdf, RDFT dataSource);
|
||||
PR_PUBLIC_API(RDF_Resource) RDF_GetResource(RDF db, char* id, PRBool createp);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_ReleaseResource(RDF db, RDF_Resource resource);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteAllArcs(RDF rdfDB, RDF_Resource source);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Update(RDF rdfDB, RDF_Resource u);
|
||||
|
||||
PR_PUBLIC_API(RDF_Notification) RDF_AddNotifiable (RDF rdfDB, RDF_NotificationProc callBack, RDF_Event ev, void* pdata);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DeleteNotifiable (RDF_Notification ns);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_Assert(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_AssertFalse(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_Unassert(RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_CanAssert(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_CanAssertFalse(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
PR_PUBLIC_API(PRBool) RDF_CanUnassert(RDF rdfDB, RDF_Resource u, RDF_Resource arcLabel, void* v, RDF_ValueType targetType);
|
||||
|
||||
|
||||
PR_PUBLIC_API(PRBool) RDF_HasAssertion (RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
void* target, RDF_ValueType targetType, PRBool tv);
|
||||
PR_PUBLIC_API(void*) RDF_GetSlotValue (RDF rdfDB, RDF_Resource u, RDF_Resource s, RDF_ValueType targetType,
|
||||
PRBool inversep, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_GetTargets (RDF rdfDB, RDF_Resource source, RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_GetSources (RDF rdfDB, RDF_Resource target, RDF_Resource arcLabel,
|
||||
RDF_ValueType sourceType, PRBool tv);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_ArcLabelsOut (RDF rdfDB, RDF_Resource u);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_ArcLabelsIn (RDF rdfDB, RDF_Resource u);
|
||||
PR_PUBLIC_API(void*) RDF_NextValue(RDF_Cursor c);
|
||||
PR_PUBLIC_API(char*) RDF_ValueDataSource(RDF_Cursor c);
|
||||
PR_PUBLIC_API(RDF_ValueType) RDF_CursorValueType(RDF_Cursor c);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_DisposeCursor (RDF_Cursor c);
|
||||
|
||||
|
||||
|
||||
/*** Guha needs to get his act together and figure out how to do this.
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Undo(RDF rdf);
|
||||
***/
|
||||
|
||||
/* These two should be removed soon. They are here because Nav Center
|
||||
depends on them. */
|
||||
|
||||
/* PR_PUBLIC_API(RDF_Error) RDF_Init(char *profileDirURL); */
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Init(RDF_InitParams params);
|
||||
PR_PUBLIC_API(RDF_Error) RDF_Shutdown(void);
|
||||
|
||||
/* the stuff in vocab.h will supercede whats below. I am leaving this here
|
||||
only for the very near future */
|
||||
|
||||
|
||||
/** utilities : move out of here!!! **/
|
||||
/* well known resources */
|
||||
|
||||
|
||||
PR_PUBLIC_API(char*) RDF_GetResourceName(RDF rdfDB, RDF_Resource node);
|
||||
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetFirstInstance (RDF_Resource type, char* defaultURL);
|
||||
PR_PUBLIC_API(void) RDFUtil_SetFirstInstance (RDF_Resource type, RDF_Resource item);
|
||||
|
||||
typedef void (*printProc)(void* data, char* str);
|
||||
PR_PUBLIC_API(void) outputMCFTree (RDF db, printProc printer, void* data, RDF_Resource node);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetBreadcrumb();
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetQuickFileFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetQuickFileFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetPTFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetPTFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Cursor) RDF_Find (RDF_Resource s, RDF_Resource match, void* v, RDF_ValueType type);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetNewBookmarkFolder();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetNewBookmarkFolder(RDF_Resource container);
|
||||
PR_PUBLIC_API(RDF_Resource) RDFUtil_GetDefaultSelectedView();
|
||||
PR_PUBLIC_API(void) RDFUtil_SetDefaultSelectedView(RDF_Resource container);
|
||||
|
||||
/** end utilities **/
|
||||
|
||||
/* this stuff is stuck in here for netlib */
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif /* rdfc_h__ */
|
||||
229
mozilla/modules/rdf/include/vocab.h
Normal file
@@ -0,0 +1,229 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_VOCAB_H_
|
||||
#define _RDF_VOCAB_H_
|
||||
|
||||
typedef struct _RDF_CoreVocabStruct {
|
||||
RDF_Resource RDF_parent;
|
||||
RDF_Resource RDF_name;
|
||||
RDF_Resource RDF_instanceOf;
|
||||
RDF_Resource RDF_subClassOf;
|
||||
RDF_Resource RDF_PropertyType;
|
||||
RDF_Resource RDF_Class;
|
||||
RDF_Resource RDF_slotsHere;
|
||||
RDF_Resource RDF_slotsIn;
|
||||
RDF_Resource RDF_domain;
|
||||
RDF_Resource RDF_range;
|
||||
RDF_Resource RDF_StringType;
|
||||
RDF_Resource RDF_IntType;
|
||||
RDF_Resource RDF_equals;
|
||||
RDF_Resource RDF_lessThan;
|
||||
RDF_Resource RDF_greaterThan;
|
||||
RDF_Resource RDF_lessThanOrEqual;
|
||||
RDF_Resource RDF_greaterThanOrEqual;
|
||||
RDF_Resource RDF_stringEquals;
|
||||
RDF_Resource RDF_stringNotEquals;
|
||||
RDF_Resource RDF_substring;
|
||||
RDF_Resource RDF_stringStartsWith;
|
||||
RDF_Resource RDF_stringEndsWith;
|
||||
RDF_Resource RDF_child;
|
||||
RDF_Resource RDF_comment;
|
||||
RDF_Resource RDF_content;
|
||||
RDF_Resource RDF_summary;
|
||||
} RDF_CoreVocabStruct;
|
||||
|
||||
typedef RDF_CoreVocabStruct* RDF_CoreVocab;
|
||||
|
||||
typedef struct _RDF_NCVocabStruct {
|
||||
RDF_Resource RDF_overview;
|
||||
RDF_Resource RDF_Trash;
|
||||
RDF_Resource RDF_Clipboard;
|
||||
RDF_Resource RDF_Top;
|
||||
RDF_Resource RDF_Search;
|
||||
RDF_Resource RDF_Sitemaps;
|
||||
RDF_Resource RDF_BreadCrumbCategory;
|
||||
RDF_Resource RDF_BookmarkFolderCategory;
|
||||
RDF_Resource RDF_NewBookmarkFolderCategory;
|
||||
RDF_Resource RDF_History;
|
||||
RDF_Resource RDF_HistoryBySite;
|
||||
RDF_Resource RDF_HistoryByDate;
|
||||
RDF_Resource RDF_HistoryMostVisited;
|
||||
|
||||
/* IE items */
|
||||
RDF_Resource RDF_IEBookmarkFolderCategory;
|
||||
RDF_Resource RDF_IEHistory;
|
||||
|
||||
RDF_Resource RDF_bookmarkAddDate;
|
||||
RDF_Resource RDF_PersonalToolbarFolderCategory;
|
||||
RDF_Resource RDF_Column;
|
||||
RDF_Resource RDF_ColumnResource;
|
||||
RDF_Resource RDF_ColumnWidth;
|
||||
RDF_Resource RDF_ColumnIconURL;
|
||||
RDF_Resource RDF_ColumnDataType;
|
||||
RDF_Resource RDF_smallIcon; /* Small normal icon. */
|
||||
RDF_Resource RDF_largeIcon; /* Large normal icon. */
|
||||
RDF_Resource RDF_Guide;
|
||||
RDF_Resource RDF_HTMLURL;
|
||||
RDF_Resource RDF_HTMLHeight;
|
||||
RDF_Resource RDF_LocalFiles;
|
||||
RDF_Resource RDF_FTP;
|
||||
RDF_Resource RDF_Appletalk;
|
||||
RDF_Resource RDF_Mail;
|
||||
RDF_Resource RDF_Password;
|
||||
RDF_Resource RDF_SBProviders;
|
||||
RDF_Resource RDF_WorkspacePos;
|
||||
RDF_Resource RDF_ItemPos;
|
||||
RDF_Resource RDF_Locks;
|
||||
RDF_Resource RDF_AddLock;
|
||||
RDF_Resource RDF_DeleteLock;
|
||||
RDF_Resource RDF_IconLock;
|
||||
RDF_Resource RDF_NameLock;
|
||||
RDF_Resource RDF_CopyLock;
|
||||
RDF_Resource RDF_MoveLock;
|
||||
RDF_Resource RDF_WorkspacePosLock;
|
||||
RDF_Resource RDF_DefaultSelectedView;
|
||||
RDF_Resource RDF_AutoOpen;
|
||||
RDF_Resource RDF_resultType;
|
||||
RDF_Resource RDF_methodType;
|
||||
RDF_Resource RDF_prompt;
|
||||
RDF_Resource RDF_HTMLType;
|
||||
RDF_Resource RDF_URLShortcut;
|
||||
RDF_Resource RDF_Poll;
|
||||
RDF_Resource RDF_PollInterval;
|
||||
RDF_Resource RDF_PollURL;
|
||||
|
||||
RDF_Resource RDF_Cookies;
|
||||
#ifdef TRANSACTION_RECEIPTS
|
||||
RDF_Resource RDF_Receipts;
|
||||
#endif
|
||||
RDF_Resource RDF_Toolbar;
|
||||
RDF_Resource RDF_JSec;
|
||||
RDF_Resource RDF_JSecPrincipal;
|
||||
RDF_Resource RDF_JSecTarget;
|
||||
RDF_Resource RDF_JSecAccess;
|
||||
|
||||
/* Commands */
|
||||
|
||||
RDF_Resource RDF_Command;
|
||||
RDF_Resource RDF_Command_Launch;
|
||||
RDF_Resource RDF_Command_Refresh;
|
||||
RDF_Resource RDF_Command_Reveal;
|
||||
RDF_Resource RDF_Command_Atalk_FlatHierarchy;
|
||||
RDF_Resource RDF_Command_Atalk_Hierarchy;
|
||||
|
||||
/* NavCenter appearance styles */
|
||||
|
||||
RDF_Resource viewFGColor;
|
||||
RDF_Resource viewBGColor;
|
||||
RDF_Resource viewBGURL;
|
||||
RDF_Resource showTreeConnections;
|
||||
RDF_Resource treeConnectionFGColor;
|
||||
RDF_Resource treeOpenTriggerIconURL;
|
||||
RDF_Resource treeClosedTriggerIconURL;
|
||||
RDF_Resource selectionFGColor;
|
||||
RDF_Resource selectionBGColor;
|
||||
RDF_Resource columnHeaderFGColor;
|
||||
RDF_Resource columnHeaderBGColor;
|
||||
RDF_Resource columnHeaderBGURL;
|
||||
RDF_Resource showColumnHeaders;
|
||||
RDF_Resource showColumnHeaderDividers;
|
||||
RDF_Resource showTitleBar; /* Whether or not to show the title bar at all */
|
||||
RDF_Resource showControlStrip; /* Whether or not to show the control strip at all. */
|
||||
|
||||
RDF_Resource sortColumnFGColor;
|
||||
RDF_Resource sortColumnBGColor;
|
||||
RDF_Resource titleBarFGColor;
|
||||
RDF_Resource titleBarBGColor;
|
||||
RDF_Resource titleBarBGURL;
|
||||
RDF_Resource titleBarShowText;
|
||||
RDF_Resource dividerColor;
|
||||
RDF_Resource showDivider;
|
||||
RDF_Resource selectedColumnHeaderFGColor;
|
||||
RDF_Resource selectedColumnHeaderBGColor;
|
||||
RDF_Resource showColumnHilite;
|
||||
RDF_Resource triggerPlacement;
|
||||
|
||||
/* NavCenter behavior flags */
|
||||
|
||||
RDF_Resource useInlineEditing;
|
||||
RDF_Resource useSingleClick;
|
||||
RDF_Resource loadOpenState;
|
||||
RDF_Resource saveOpenState;
|
||||
|
||||
/* Toolbar Appearance Styles */
|
||||
RDF_Resource toolbarBitmapPosition; /* Bitmap's position ("side"/"top") */
|
||||
RDF_Resource toolbarDisplayMode;
|
||||
RDF_Resource toolbarCollapsed;
|
||||
RDF_Resource toolbarVisible;
|
||||
RDF_Resource toolbarRolloverIcon; /* The icon to display on rollover. */
|
||||
RDF_Resource toolbarPressedIcon; /* The icon to display on a press. */
|
||||
RDF_Resource toolbarDisabledIcon; /* The icon to display when disabled. */
|
||||
RDF_Resource toolbarEnabledIcon; /* THe icon to display when enabled. */
|
||||
|
||||
/* Cookie Stuff */
|
||||
RDF_Resource cookieDomain;
|
||||
RDF_Resource cookieValue;
|
||||
RDF_Resource cookieHost;
|
||||
RDF_Resource cookiePath;
|
||||
RDF_Resource cookieSecure;
|
||||
RDF_Resource cookieExpires;
|
||||
|
||||
RDF_Resource toolbarButtonsFixedSize; /* Whether or not the buttons must be the same size ("yes"/"no") */
|
||||
RDF_Resource viewRolloverColor; /* What to display when an item is rolled over in a view.*/
|
||||
RDF_Resource viewPressedColor; /* What to display when an item is pressed in a view. */
|
||||
RDF_Resource viewDisabledColor; /* Color to use when item is disabled in a view. */
|
||||
RDF_Resource urlBar; /* Whether or not the button is a URL bar. */
|
||||
RDF_Resource urlBarWidth; /* The width of the URL bar. */
|
||||
|
||||
RDF_Resource buttonTreeState; /* The tree state (docked, popup) for a button. */
|
||||
RDF_Resource buttonTooltipText; /* The tooltip text for a button. */
|
||||
RDF_Resource buttonStatusbarText; /* The status bar text for a button. */
|
||||
RDF_Resource buttonBorderStyle; /* What type of border the button should have. */
|
||||
|
||||
RDF_Resource controlStripFGColor; /* The tree's control strip foreground */
|
||||
RDF_Resource controlStripBGColor; /* The tree's control strip background */
|
||||
RDF_Resource controlStripBGURL; /* The tree's control strip BG URL */
|
||||
RDF_Resource controlStripCloseText; /* The text displayed for the close function in the control strip. */
|
||||
|
||||
RDF_Resource pos;
|
||||
RDF_Resource from;
|
||||
RDF_Resource to;
|
||||
RDF_Resource subject;
|
||||
RDF_Resource date;
|
||||
RDF_Resource displayURL;
|
||||
} RDF_NCVocabStruct;
|
||||
|
||||
typedef RDF_NCVocabStruct* RDF_NCVocab;
|
||||
|
||||
typedef struct _RDF_WDVocabStruct {
|
||||
RDF_Resource RDF_URL;
|
||||
RDF_Resource RDF_description;
|
||||
RDF_Resource RDF_keyword;
|
||||
RDF_Resource RDF_Container;
|
||||
RDF_Resource RDF_firstVisitDate;
|
||||
RDF_Resource RDF_lastVisitDate;
|
||||
RDF_Resource RDF_numAccesses;
|
||||
RDF_Resource RDF_creationDate;
|
||||
RDF_Resource RDF_lastModifiedDate;
|
||||
RDF_Resource RDF_size;
|
||||
} RDF_WDVocabStruct;
|
||||
|
||||
typedef RDF_WDVocabStruct* RDF_WDVocab;
|
||||
|
||||
#endif
|
||||
27
mozilla/modules/rdf/macbuild/RDF.Prefix
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
#include "RDFConfig.h"
|
||||
193
mozilla/modules/rdf/macbuild/RDF.exp
Normal file
@@ -0,0 +1,193 @@
|
||||
###
|
||||
### Symbols you may have to hand annotate with #{code} or #{data}...
|
||||
###
|
||||
|
||||
HT_CanDropHTROn
|
||||
HT_CanDropURLOn
|
||||
HT_DeleteCursor
|
||||
HT_DeleteView
|
||||
HT_DropHTROn
|
||||
HT_DropURLOn
|
||||
HT_GetNextItem
|
||||
HT_GetNotificationMask
|
||||
HT_GetNthItem
|
||||
HT_GetNthItemInt
|
||||
HT_GetOpenState
|
||||
HT_GetParent
|
||||
HT_GetRDFResource
|
||||
HT_GetSelectedState
|
||||
HT_GetView
|
||||
HT_GetViewData
|
||||
HT_IsContainer
|
||||
HT_IsContainerOpen
|
||||
HT_IsSelected
|
||||
HT_KillResource
|
||||
HT_MakeNewContainer
|
||||
HT_NewCursor
|
||||
HT_NewView
|
||||
HT_NodeDisplayString
|
||||
HT_RemoveChild
|
||||
HT_SetNotificationMask
|
||||
HT_SetOpenState
|
||||
HT_SetSelectedState
|
||||
HT_SetViewData
|
||||
HT_TopNode
|
||||
HT_WriteOutAsBookmarks
|
||||
RDF_AddNotifiable
|
||||
RDF_Assert
|
||||
RDF_CanAssert
|
||||
RDF_CanUnassert
|
||||
RDF_Create
|
||||
RDF_DeleteNotifiable
|
||||
RDF_DisposeCursor
|
||||
RDF_GetSlotValue
|
||||
RDF_GetSlotValues
|
||||
RDF_HasAssertion
|
||||
RDF_Init
|
||||
RDF_InitLocalStores
|
||||
RDF_Kill
|
||||
RDF_NextValue
|
||||
RDF_SaveState
|
||||
RDF_SetResourceLock
|
||||
RDF_Shutdown
|
||||
RDF_StdVocab
|
||||
RDF_Unassert
|
||||
RDF_AddCookieResource
|
||||
# RDFglueExit
|
||||
# RDFglueInitialize
|
||||
# __initialize
|
||||
# __ptmf_null
|
||||
# __terminate
|
||||
# abortRDFParse
|
||||
# addChildAfter
|
||||
# addChildBefore
|
||||
# addDescription
|
||||
# addNotifiable
|
||||
# addSlotValue
|
||||
# addToAssertionList
|
||||
# addToResourceList
|
||||
# append2Strings
|
||||
# asEqual
|
||||
# asTv
|
||||
# asType
|
||||
# assert
|
||||
# assignHeaderSlot
|
||||
# assignSlot
|
||||
# beginReadingRDFFile
|
||||
# bkStateTransition
|
||||
# bookmarkSlotp
|
||||
# charSearch
|
||||
# containerIDp
|
||||
# containerp
|
||||
# copyString
|
||||
# createBootstrapResources
|
||||
# createContainer
|
||||
# createSeparator
|
||||
# deleteNotifiable
|
||||
# derelativizeURL
|
||||
# destroyViewInt
|
||||
# disposeCursor
|
||||
# endsWith
|
||||
# exitRDF
|
||||
# fillContainer
|
||||
# finishRDFParse
|
||||
# freeAssertion
|
||||
# freeMem
|
||||
# gBookmarkURL
|
||||
# gLocalStoreURL
|
||||
# gRDFDB
|
||||
# gcRDFFile
|
||||
# getElfProp
|
||||
# getFirstToken
|
||||
# getHash
|
||||
# getMem
|
||||
# getRDFDB
|
||||
# getRelURL
|
||||
# getSlotValue
|
||||
# getSlotValues
|
||||
# globals
|
||||
# hasAssertion
|
||||
# hashIndex
|
||||
# ht_fprintf
|
||||
# htrdfNotifFunc
|
||||
# idenEqual
|
||||
# idenHash
|
||||
# initDataSources
|
||||
# initLocalStore
|
||||
# inverseTV
|
||||
# isContainer
|
||||
# isLeaf
|
||||
# isSeparator
|
||||
# isTypeOf
|
||||
# killResource
|
||||
# localStoreAdd
|
||||
# localStoreAssert
|
||||
# localStoreDisposeCursor
|
||||
# localStoreGetSlotValue
|
||||
# localStoreGetSlotValues
|
||||
# localStoreHasAssertion
|
||||
# localStoreNextValue
|
||||
# localStoreRemove
|
||||
# localStoreUnassert
|
||||
# lockedp
|
||||
# longjmp
|
||||
# makeNewAssertion
|
||||
# makeNewID
|
||||
# makeNewRDFDB
|
||||
# makeRDFFile
|
||||
# newFolderBkItem
|
||||
# newHTEntry
|
||||
# newHashtable
|
||||
# newLeafBkItem
|
||||
# nextValue
|
||||
# outputRDFTree
|
||||
# outputRDFTreeInt
|
||||
# parseNextBkBlob
|
||||
# parseNextBkToken
|
||||
# parseNextMCFBlob
|
||||
# parseNextRDFBlob
|
||||
# parseNextRDFLine
|
||||
# parseNextRDFToken
|
||||
# parseNextRDFXMLBlob
|
||||
# parseRDFElement
|
||||
# parseSlotValue
|
||||
# possiblyGCResource
|
||||
# putHash
|
||||
# rdfDB
|
||||
# rdfDBInited
|
||||
# readRDFFile
|
||||
# remHash
|
||||
# remoteAssert
|
||||
# remoteStoreAdd
|
||||
# remoteStoreDisposeCursor
|
||||
# remoteStoreGetSlotValue
|
||||
# remoteStoreGetSlotValues
|
||||
# remoteStoreHasAssertion
|
||||
# remoteStoreNextValue
|
||||
# remoteStoreRemove
|
||||
# remoteUnassert
|
||||
# resolveGenlPosReference
|
||||
# resolveReference
|
||||
# resourceDescription
|
||||
# resourceFromID
|
||||
# resourceLastModifiedDate
|
||||
# resourceLastVisitDate
|
||||
# resourceName
|
||||
# resourceTransition
|
||||
# revCharSearch
|
||||
# saveLocalStore
|
||||
# sendNotification
|
||||
# sendNotifications
|
||||
# separatorCounter
|
||||
# setAsTv
|
||||
# setAsType
|
||||
# setContainerp
|
||||
# setHiddenState
|
||||
# setLockedp
|
||||
# startsWith
|
||||
# stringAppend
|
||||
# stringEquals
|
||||
# translators
|
||||
# unassert
|
||||
# urlEquals
|
||||
# writeResource
|
||||
BIN
mozilla/modules/rdf/macbuild/RDF.mcp
Normal file
18
mozilla/modules/rdf/macbuild/RDFConfig.h
Normal file
@@ -0,0 +1,18 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
#define CGLUESUPPORTED 0 // turn off C glue support to avoid conflict on create() in RDF
|
||||
27
mozilla/modules/rdf/macbuild/RDFDebug.Prefix
Normal file
@@ -0,0 +1,27 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#include "MacPrefix_debug.h"
|
||||
#include "RDFConfig.h"
|
||||
29
mozilla/modules/rdf/macbuild/RDFNoLDAP.Prefix
Normal file
@@ -0,0 +1,29 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#define MOZ_LITE 1
|
||||
#define DEVELOPER_DEBUG 1
|
||||
#include "RDFConfig.h"
|
||||
#include <OpenTransport.h>
|
||||
30
mozilla/modules/rdf/macbuild/RDFNoLDAPDebug.Prefix
Normal file
@@ -0,0 +1,30 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
//
|
||||
// RDFDebug.Prefix
|
||||
//
|
||||
// Global prefix file for the debug RDF project.
|
||||
//
|
||||
//
|
||||
|
||||
#define MOZ_LITE 1
|
||||
#define DEBUG 1
|
||||
#define DEVELOPER_DEBUG 1
|
||||
#include "RDFConfig.h"
|
||||
#include <OpenTransport.h>
|
||||
9
mozilla/modules/rdf/makefile.win
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
DEPTH=..\..
|
||||
|
||||
DIRS=\
|
||||
include \
|
||||
src \
|
||||
$(NULL)
|
||||
|
||||
include <$(DEPTH)\config\rules.mak>
|
||||
46
mozilla/modules/rdf/src/Makefile
Normal file
@@ -0,0 +1,46 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
MODULE = rdf
|
||||
LIBRARY_NAME = $(LITE_PREFIX)rdf
|
||||
LIBXP = $(DIST)/lib/libxp.$(LIB_SUFFIX)
|
||||
|
||||
REQUIRES = nspr
|
||||
|
||||
JNI_GEN = netscape.rdf.core.NativeRDF netscape.rdf.core.NativeRDFEnumeration
|
||||
|
||||
CSRCS = \
|
||||
vocab.c \
|
||||
mcf.c \
|
||||
remstore.c \
|
||||
utils.c \
|
||||
rdfparse.c \
|
||||
bmk2mcf.c \
|
||||
rdfht.c \
|
||||
columns.c \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/rdf
|
||||
|
||||
include $(DEPTH)/config/rules.mk
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
87
mozilla/modules/rdf/src/Makefile.in
Normal file
@@ -0,0 +1,87 @@
|
||||
#!gmake
|
||||
#
|
||||
# The contents of this file are subject to the Netscape Public License
|
||||
# Version 1.0 (the "NPL"); you may not use this file except in
|
||||
# compliance with the NPL. You may obtain a copy of the NPL at
|
||||
# http://www.mozilla.org/NPL/
|
||||
#
|
||||
# Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
# for the specific language governing rights and limitations under the
|
||||
# NPL.
|
||||
#
|
||||
# The Initial Developer of this code under the NPL is Netscape
|
||||
# Communications Corporation. Portions created by Netscape are
|
||||
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
# Reserved.
|
||||
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
DEPTH = ../../..
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
MODULE = rdf
|
||||
LIBRARY_NAME = $(LITE_PREFIX)rdf
|
||||
LIBXP = $(DIST)/lib/libxp.$(LIB_SUFFIX)
|
||||
|
||||
REQUIRES = nspr dbm java js htmldlgs util img layer pref ldap network parse
|
||||
|
||||
JNI_GEN = netscape.rdf.core.NativeRDF netscape.rdf.core.NativeRDFEnumeration
|
||||
|
||||
CSRCS = \
|
||||
vocab.c \
|
||||
mcf.c \
|
||||
remstore.c \
|
||||
utils.c \
|
||||
rdfparse.c \
|
||||
mcff2mcf.c \
|
||||
bmk2mcf.c \
|
||||
ldap2rdf.c \
|
||||
glue.c \
|
||||
rdfht.c \
|
||||
jsec2rdf.c \
|
||||
$(NULL)
|
||||
|
||||
ifndef RDF_STANDALONE
|
||||
CSRCS += \
|
||||
nlcstore.c \
|
||||
find2rdf.c \
|
||||
fs2rdf.c \
|
||||
hist2rdf.c \
|
||||
pm2rdf.c \
|
||||
es2mcf.c \
|
||||
columns.c \
|
||||
ht.c \
|
||||
$(NULL)
|
||||
endif
|
||||
|
||||
SPF_OBJS = $(OBJDIR)/spf2ldif.o \
|
||||
$(OBJDIR)/hashtable.o
|
||||
|
||||
LOCAL_INCLUDES = -I$(PUBLIC)/rdf
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
||||
|
||||
ifdef RDF_STANDALONE
|
||||
DEFINES := $(filter-out -DMOZILLA_CLIENT, $(DEFINES))
|
||||
endif
|
||||
|
||||
$(LIBRARY): $(OBJS)
|
||||
|
||||
test: $(OBJDIR)/test
|
||||
spf2ldif: $(OBJDIR)/spf2ldif
|
||||
|
||||
.PHONY: test spf2ldif
|
||||
|
||||
$(OBJDIR)/test: $(OBJDIR)/test.o $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(OBJDIR)/test.o $(LIBRARY) $(LIBNSPR) $(LIBXP) $(LDFLAGS) $(OS_LIBS)
|
||||
|
||||
$(OBJDIR)/spf2ldif: $(SPF_OBJS) $(LIBRARY)
|
||||
@$(MAKE_OBJDIR)
|
||||
$(CC) -o $@ $(SPF_OBJS) $(LIBRARY) $(LIBNSPR) $(LIBXP) $(LDFLAGS) $(OS_LIBS)
|
||||
1235
mozilla/modules/rdf/src/atalk.c
Normal file
87
mozilla/modules/rdf/src/atalk.h
Normal file
@@ -0,0 +1,87 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_ATALK_H_
|
||||
#define _RDF_ATALK_H_
|
||||
|
||||
#ifdef XP_MAC
|
||||
|
||||
#include <Appletalk.h>
|
||||
#include <Devices.h>
|
||||
#include <Gestalt.h>
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "mcf.h"
|
||||
#include "vocab.h"
|
||||
#include "utils.h"
|
||||
#include "prefapi.h"
|
||||
|
||||
|
||||
/* atalk.c data structures and defines */
|
||||
|
||||
extern int RDF_APPLETALK_TOP_NAME, RDF_AFP_CLIENT_37_STR, RDF_AFP_AUTH_FAILED_STR;
|
||||
extern int RDF_AFP_PW_EXPIRED_STR, RDF_AFP_ALREADY_MOUNTED_STR, RDF_AFP_MAX_SERVERS_STR;
|
||||
extern int RDF_AFP_NOT_RESPONDING_STR, RDF_AFP_SAME_NODE_STR, RDF_AFP_ERROR_NUM_STR;
|
||||
extern int RDF_VOLUME_DESC_STR, RDF_DIRECTORY_DESC_STR, RDF_FILE_DESC_STR;
|
||||
|
||||
#define ATALK_NOHIERARCHY_PREF "browser.navcenter.appletalk.zone.nohierarchy"
|
||||
|
||||
#define ATALK_CMD_PREFIX "Command:at:"
|
||||
|
||||
#define kAppleShareVerGestalt 'afps'
|
||||
#define kAppleShareVer_3_7 0x00000006
|
||||
#define AFPX_PROT_VERSION 0
|
||||
#define BASE_AFPX_OFFSET 30
|
||||
#define BASE_AFP_OFFSET 24
|
||||
|
||||
typedef struct _ourNBPUserDataStruct
|
||||
{
|
||||
RDFT rdf;
|
||||
char *parentID;
|
||||
} ourNBPUserDataStruct;
|
||||
typedef ourNBPUserDataStruct *ourNBPUserDataPtr;
|
||||
|
||||
|
||||
/* atalk.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef XP_MAC
|
||||
PRBool isAFPVolume(short ioVRefNum);
|
||||
#endif
|
||||
|
||||
void getZones(RDFT rdf);
|
||||
void processZones(RDFT rdf, char *zones, uint16 numZones, XP_Bool noHierarchyFlag);
|
||||
void checkServerLookup (MPPParamBlock *nbp);
|
||||
void getServers(RDFT rdf, RDF_Resource parent);
|
||||
void AtalkPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Error AtalkDestroy (RDFT r);
|
||||
PRBool AtalkHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
||||
PRBool AtalkAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void *v, RDF_ValueType type, PRBool tv);
|
||||
char * convertAFPtoUnescapedFile(char *id);
|
||||
void * AtalkGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor AtalkGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * AtalkNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Resource CreateAFPFSUnit (char *nname, PRBool isDirectoryFlag);
|
||||
RDFT MakeAtalkStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
602
mozilla/modules/rdf/src/bmk2mcf.c
Normal file
@@ -0,0 +1,602 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/* Reading bookmarks.htm into rdf.
|
||||
tags in the bookmark file.
|
||||
<TITLE>
|
||||
<H1>
|
||||
<H3>
|
||||
<DL></DL>
|
||||
<DT>
|
||||
<P>
|
||||
|
||||
<DT> indicates that an item is coming.
|
||||
If the next item is an <a then we have a url
|
||||
If the next item is a h3, we have a folder.
|
||||
<DL> indicates that the previous item (which should have been a folder)
|
||||
is the parent of the next set.
|
||||
</DL> indicates pop out a level
|
||||
<P> ignore this on reading, but write out one after each <DL>
|
||||
<DD> the description for the previous <DT>
|
||||
|
||||
Category urls. Make it up out of the add dates. */
|
||||
|
||||
|
||||
/*
|
||||
This file translates netscape bookmarks into the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
|
||||
#include "bmk2mcf.h"
|
||||
#include "utils.h"
|
||||
#include "time.h"
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
/* extern declarations */
|
||||
PR_PUBLIC_API(void) HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u); /* XXX this should be elsewhere */
|
||||
extern char *gBookmarkURL;
|
||||
extern RDF gNCDB;
|
||||
|
||||
/* globals */
|
||||
uint16 separatorCounter = 0;
|
||||
static char* gBkFolderDate;
|
||||
static RDFT gBMKStore = 0;
|
||||
extern int RDF_PERSONAL_TOOLBAR_NAME;
|
||||
|
||||
RDF_Resource
|
||||
createSeparator(void)
|
||||
{
|
||||
char url[50];
|
||||
RDF_Resource sep;
|
||||
PR_snprintf(url, 50, "separator%i", separatorCounter++);
|
||||
sep = RDF_GetResource(NULL, url, 1);
|
||||
return sep;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
RDF_Resource
|
||||
createContainer (char* id)
|
||||
{
|
||||
RDF_Resource r = RDF_GetResource(NULL, id, true);
|
||||
setContainerp(r, 1);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
char *
|
||||
resourceDescription (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_description, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
resourceLastVisitDate (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastVisitDate, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
resourceLastModifiedDate (RDF rdf, RDF_Resource r)
|
||||
{
|
||||
return (char*)RDF_GetSlotValue(rdf, r, gWebData->RDF_lastModifiedDate, RDF_STRING_TYPE, false, true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextBkBlob (RDFFile f, char* blob, int32 size)
|
||||
{
|
||||
int32 n, last, m;
|
||||
PRBool somethingseenp = false;
|
||||
n = last = 0;
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
somethingseenp = false;
|
||||
memset(f->line, '\0', f->lineSize);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
somethingseenp = true;
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
while ((m < 300) && (c != '<') && (c != '>') && (n < size)) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
somethingseenp = (somethingseenp || ((c != ' ') && (c != '\r') && (c != '\n')));
|
||||
n++;
|
||||
c = blob[n];
|
||||
}
|
||||
if (c == '>') f->line[m] = c;
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '<') || (c == '>')) {
|
||||
last = n;
|
||||
if (c == '<') f->holdOver[0] = '<';
|
||||
if (somethingseenp == true) parseNextBkToken(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
} else if (c == '<') f->holdOver[0] = '<';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextBkToken (RDFFile f, char* token)
|
||||
{
|
||||
/* printf(token); */
|
||||
if (token[0] == '<') {
|
||||
bkStateTransition(f, token);
|
||||
} else {
|
||||
/* ok, we have a piece of content.
|
||||
can be the title, or a description or */
|
||||
if ((f->status == IN_TITLE) || (f->status == IN_H3) ||
|
||||
(f->status == IN_ITEM_TITLE)) {
|
||||
if (IN_H3 && gBkFolderDate) {
|
||||
char *url;
|
||||
RDF_Resource newFolder;
|
||||
url = PR_smprintf("%s%s.rdf", gBkFolderDate, token);
|
||||
newFolder = createContainer(url);
|
||||
free(url);
|
||||
addSlotValue(f,newFolder, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
freeMem(gBkFolderDate);
|
||||
gBkFolderDate = NULL;
|
||||
f->lastItem = newFolder;
|
||||
}
|
||||
if ((f->db == gLocalStore) || (f->status != IN_TITLE))
|
||||
{
|
||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_name,
|
||||
copyString(token), RDF_STRING_TYPE, NULL);
|
||||
}
|
||||
|
||||
if (startsWith("Personal Toolbar", token) && (containerp(f->lastItem)))
|
||||
addSlotValue(f, f->lastItem, gCoreVocab->RDF_instanceOf,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
RDF_RESOURCE_TYPE, "true");
|
||||
|
||||
} else if (f->status == IN_ITEM_DESCRIPTION) {
|
||||
addDescription(f, f->lastItem, token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
addDescription (RDFFile f, RDF_Resource r, char* token)
|
||||
{
|
||||
char* desc = (char*) remoteStoreGetSlotValue(gLocalStore, r, gWebData->RDF_description,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
if (desc == NULL) {
|
||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
||||
copyString(token),
|
||||
RDF_STRING_TYPE, NULL);
|
||||
} else {
|
||||
addSlotValue(f, f->lastItem, gWebData->RDF_description,
|
||||
append2Strings(desc, token), RDF_STRING_TYPE, NULL);
|
||||
remoteUnassert(gLocalStore, f->lastItem, gWebData->RDF_description, desc, RDF_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
bkStateTransition (RDFFile f, char* token)
|
||||
{
|
||||
if (startsWith("<A", token)) {
|
||||
newLeafBkItem(f, token);
|
||||
f->status = IN_ITEM_TITLE;
|
||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
||||
newFolderBkItem(f, token);
|
||||
f->status = IN_H3;
|
||||
} else if (startsWith(OPEN_TITLE_STRING, token)) {
|
||||
f->status = IN_TITLE;
|
||||
} else if (startsWith(OPEN_H3_STRING, token)) {
|
||||
f->status = IN_H3;
|
||||
} else if (startsWith(DD_STRING, token)) {
|
||||
if (remoteStoreGetSlotValue(gLocalStore, f->lastItem, gWebData->RDF_description,
|
||||
RDF_STRING_TYPE, false, true)
|
||||
== NULL) f->status = IN_ITEM_DESCRIPTION;
|
||||
} else if (startsWith(OPEN_DL_STRING, token)) {
|
||||
f->stack[f->depth++] = f->lastItem;
|
||||
} else if (startsWith(CLOSE_DL_STRING, token)) {
|
||||
f->depth--;
|
||||
} else if (startsWith("<HR>", token)) {
|
||||
addSlotValue(f, createSeparator(), gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
f->status = 0;
|
||||
} else if ((f->status == IN_ITEM_DESCRIPTION) && (startsWith("<BR>", token))) {
|
||||
addDescription(f, f->lastItem, token);
|
||||
} else f->status = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
newFolderBkItem(RDFFile f, char* token)
|
||||
{
|
||||
int16 start, end;
|
||||
start = charSearch('"', token);
|
||||
end = revCharSearch('"', token);
|
||||
token[end] = '\0';
|
||||
gBkFolderDate = copyString(&token[start+1]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
newLeafBkItem (RDFFile f, char* token)
|
||||
{
|
||||
char buffer[128];
|
||||
struct tm *time;
|
||||
uint32 dateVal;
|
||||
char* url = NULL;
|
||||
char* addDate = NULL;
|
||||
char* lastVisit = NULL;
|
||||
char* lastModified = NULL;
|
||||
uint8 current = 0;
|
||||
int32 len = RDF_STRLEN(token);
|
||||
int32 n = 0;
|
||||
char c = token[n++];
|
||||
PRBool inString = false;
|
||||
RDF_Resource newR;
|
||||
|
||||
while (n < len) {
|
||||
if (c == '"') {
|
||||
if (inString) {
|
||||
token[n-1] = '\0';
|
||||
inString = false;
|
||||
} else {
|
||||
inString = true;
|
||||
if (current == 0) {
|
||||
url = &token[n];
|
||||
} else if (current == 1) {
|
||||
addDate = &token[n];
|
||||
} else if (current == 2) {
|
||||
lastVisit = &token[n];
|
||||
} else if (current == 3) {
|
||||
lastModified = &token[n];
|
||||
}
|
||||
current++;
|
||||
}
|
||||
}
|
||||
c = token[n++];
|
||||
}
|
||||
if (url == NULL) return;
|
||||
newR = RDF_GetResource(NULL, url, true);
|
||||
addSlotValue(f, newR, gCoreVocab->RDF_parent, f->stack[f->depth-1],
|
||||
RDF_RESOURCE_TYPE, NULL);
|
||||
/* addSlotValue(f, newR, gWebData->RDF_URL, (void*)copyString(url),
|
||||
RDF_STRING_TYPE, true); */
|
||||
if (addDate != NULL)
|
||||
{
|
||||
dateVal = atol(addDate);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
|
||||
addSlotValue(f, newR, gNavCenter->RDF_bookmarkAddDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (lastVisit != NULL)
|
||||
{
|
||||
dateVal = atol(lastVisit);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
addSlotValue(f, newR, gWebData->RDF_lastVisitDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (lastModified != NULL)
|
||||
{
|
||||
dateVal = atol(lastModified);
|
||||
if ((time = localtime((time_t *) &dateVal)) != NULL)
|
||||
{
|
||||
/* xxx
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
addSlotValue(f, newR, gWebData->RDF_lastModifiedDate,
|
||||
(void*)copyString(buffer), RDF_STRING_TYPE, NULL);
|
||||
*/
|
||||
}
|
||||
}
|
||||
f->lastItem = newR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
numericDate(char *url)
|
||||
{
|
||||
char *date = NULL;
|
||||
int len=0;
|
||||
|
||||
if (!url) return NULL;
|
||||
while (url[len])
|
||||
{
|
||||
if (!isdigit(url[len])) break;
|
||||
++len;
|
||||
}
|
||||
if (len > 0)
|
||||
{
|
||||
if ((date = getMem(len+1)) != NULL)
|
||||
{
|
||||
strncpy(date, url, len);
|
||||
}
|
||||
}
|
||||
return(date);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
bookmarkSlotp (RDF_Resource s)
|
||||
{
|
||||
return ((s == gCoreVocab->RDF_parent) || (s == gWebData->RDF_lastVisitDate) || (s == gWebData->RDF_description) ||
|
||||
(s == gNavCenter->RDF_bookmarkAddDate) || (s == gWebData->RDF_lastModifiedDate) ||
|
||||
(s == gCoreVocab->RDF_name));
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent)
|
||||
{
|
||||
RDF_Cursor c = RDF_GetSources(rdf, u, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
RDF_Resource next;
|
||||
char *date, *name, *url;
|
||||
int loop;
|
||||
|
||||
if (c == NULL) return;
|
||||
if (u == top) {
|
||||
name = RDF_GetResourceName(rdf, u);
|
||||
ht_rjcprintf(fp, "<!DOCTYPE NETSCAPE-Bookmark-file-1>\n", NULL);
|
||||
ht_rjcprintf(fp, "<!-- This is an automatically generated file.\n", NULL);
|
||||
ht_rjcprintf(fp, "It will be read and overwritten.\n", NULL);
|
||||
ht_rjcprintf(fp, "Do Not Edit! -->\n", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "<TITLE>%s</TITLE>\n", (name) ? name:"");
|
||||
ht_rjcprintf(fp, "<H1>%s</H1>\n<DL><p>\n", (name) ? name:"");
|
||||
}
|
||||
while ((next = RDF_NextValue(c)) != NULL) {
|
||||
|
||||
url = resourceID(next);
|
||||
if (containerp(next) && (!startsWith("ftp:",url)) && (!startsWith("file:",url))
|
||||
&& (!startsWith("IMAP:", url)) && (!startsWith("nes:", url))
|
||||
&& (!startsWith("mail:", url)) && (!startsWith("cache:", url))
|
||||
&& (!startsWith("ldap:", url))) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
date = numericDate(resourceID(next));
|
||||
ht_rjcprintf(fp, "<DT><H3 ADD_DATE=\"%s\">", (date) ? date:"");
|
||||
if (date) freeMem(date);
|
||||
name = RDF_GetResourceName(rdf, next);
|
||||
ht_rjcprintf(fp, "%s</H3>\n", name);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
ht_rjcprintf(fp, "<DL><p>\n", NULL);
|
||||
HT_WriteOutAsBookmarks1(rdf, fp, next, top, indent+1);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "</DL><p>\n", NULL);
|
||||
}
|
||||
else if (isSeparator(next)) {
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
ht_rjcprintf(fp, "<HR>\n", NULL);
|
||||
}
|
||||
else {
|
||||
char* bkAddDate = (char*)RDF_GetSlotValue(rdf, next,
|
||||
gNavCenter->RDF_bookmarkAddDate,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
|
||||
for (loop=0; loop<indent; loop++) ht_rjcprintf(fp, " ", NULL);
|
||||
|
||||
ht_rjcprintf(fp, "<DT><A HREF=\"%s\" ", resourceID(next));
|
||||
date = numericDate(bkAddDate);
|
||||
ht_rjcprintf(fp, "ADD_DATE=\"%s\" ", (date) ? date: "");
|
||||
if (date) freeMem(date);
|
||||
ht_rjcprintf(fp, "LAST_VISIT=\"%s\" ", resourceLastVisitDate(rdf, next));
|
||||
ht_rjcprintf(fp, "LAST_MODIFIED=\"%s\">", resourceLastModifiedDate(rdf, next));
|
||||
ht_rjcprintf(fp, "%s</A>\n", RDF_GetResourceName(rdf, next));
|
||||
|
||||
if (resourceDescription(rdf, next) != NULL) {
|
||||
ht_rjcprintf(fp, "<DD>%s\n", resourceDescription(rdf, next));
|
||||
}
|
||||
}
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
if (u == top) {
|
||||
ht_rjcprintf(fp, "</DL>\n", NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
HT_WriteOutAsBookmarks (RDF r, PRFileDesc *fp, RDF_Resource u)
|
||||
{
|
||||
HT_WriteOutAsBookmarks1 (r, fp, u, u, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
flushBookmarks()
|
||||
{
|
||||
PRFileDesc *bkfp;
|
||||
|
||||
if (gBookmarkURL != NULL)
|
||||
{
|
||||
/*
|
||||
delete bookmark.htm as PROpen() with PR_TRUNCATE appears broken (at least on Mac)
|
||||
*/
|
||||
CallPRDeleteFileUsingFileURL(gBookmarkURL);
|
||||
|
||||
if ((bkfp = CallPROpenUsingFileURL(gBookmarkURL, (PR_WRONLY|PR_CREATE_FILE|PR_TRUNCATE),
|
||||
0644)) != NULL)
|
||||
{
|
||||
HT_WriteOutAsBookmarks(gNCDB, bkfp, gNavCenter->RDF_BookmarkFolderCategory);
|
||||
PR_Close(bkfp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
ResourceBelongsToBookmarksp (RDF_Resource r, int32 depth) {
|
||||
if (depth > 20) {
|
||||
return false;
|
||||
} else if (r == gNavCenter->RDF_BookmarkFolderCategory) {
|
||||
return 1;
|
||||
} else if (containerp(r)) {
|
||||
Assertion as = r->rarg1;
|
||||
while (as) {
|
||||
if ((as->db == gBMKStore) &&
|
||||
(as->s == gCoreVocab->RDF_parent) &&
|
||||
(as->tv == 1) &&
|
||||
(ResourceBelongsToBookmarksp((RDF_Resource)as->value, depth+1))) return 1;
|
||||
as = as->next;
|
||||
}
|
||||
return 0;
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool remoteAssert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv);
|
||||
PRBool remoteUnassert3 (RDFFile fi, RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type);
|
||||
|
||||
|
||||
PRBool
|
||||
bmkUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s,
|
||||
void* v, RDF_ValueType type) {
|
||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
||||
return (remoteStoreRemove(mcf, u, s, v, type) != NULL);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
bmkAssert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) {
|
||||
if (ResourceBelongsToBookmarksp(u, 0)) {
|
||||
return (remoteStoreAdd(mcf, u, s, v, type, tv) != NULL);
|
||||
} else return 0;
|
||||
}
|
||||
|
||||
extern RDF_Resource gPTFolder;
|
||||
void
|
||||
readInBookmarks()
|
||||
{
|
||||
/* RDF_Resource ptFolder; */
|
||||
RDF_Resource bmk = RDF_GetResource(NULL, "NC:Bookmarks", true);
|
||||
RDFFile f = makeRDFFile(gBookmarkURL, bmk, true);
|
||||
PRFileDesc *fp;
|
||||
int32 len;
|
||||
char buf[512];
|
||||
f->fileType = RDF_BOOKMARKS;
|
||||
f->db = gBMKStore;
|
||||
f->assert = remoteAssert3;
|
||||
|
||||
fp = CallPROpenUsingFileURL(f->url, PR_RDONLY|PR_CREATE_FILE, 0644);
|
||||
if (fp == NULL) return;
|
||||
while((len=PR_Read(fp, buf, sizeof(buf))) >0) {
|
||||
parseNextBkBlob(f, buf, len);
|
||||
}
|
||||
|
||||
gPTFolder = remoteStoreGetSlotValue(f->db,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
gCoreVocab->RDF_instanceOf, RDF_RESOURCE_TYPE, true, true);
|
||||
|
||||
if (gPTFolder == NULL) {
|
||||
if ((gPTFolder = createContainer("personaltoolbar.rdf")) != NULL) {
|
||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_instanceOf,
|
||||
gNavCenter->RDF_PersonalToolbarFolderCategory,
|
||||
RDF_RESOURCE_TYPE, "true");
|
||||
addSlotValue(f, gPTFolder, gCoreVocab->RDF_name,
|
||||
copyString("Personal Toolbar"),
|
||||
RDF_STRING_TYPE, "true");
|
||||
RDFUtil_SetPTFolder(gPTFolder);
|
||||
}
|
||||
}
|
||||
|
||||
PR_Close(fp);
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
}
|
||||
|
||||
|
||||
RDFT
|
||||
MakeBMKStore (char* url)
|
||||
{
|
||||
if (startsWith("rdf:bookmarks", url)) {
|
||||
if (gBMKStore == 0) {
|
||||
RDFT ntr = gBMKStore = NewRemoteStore(url);
|
||||
ntr->assert = bmkAssert;
|
||||
ntr->unassert = bmkUnassert;
|
||||
readInBookmarks();
|
||||
return ntr;
|
||||
} else return gBMKStore;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
72
mozilla/modules/rdf/src/bmk2mcf.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_BMK2MCF_H_
|
||||
#define _RDF_BMK2MCF_H_
|
||||
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "vocab.h"
|
||||
#include "stdio.h"
|
||||
#include "ctype.h"
|
||||
|
||||
|
||||
/* bmk2mcf.c data structures and defines */
|
||||
|
||||
#define OPEN_TITLE_STRING "<TITLE>"
|
||||
#define CLOSE_TITLE_STRING "</TITLE>"
|
||||
#define OPEN_H1_STRING "<H1>"
|
||||
#define CLOSE_H1_STRING "</H1>"
|
||||
#define OPEN_H3_STRING "<H3"
|
||||
#define CLOSE_H3_STRING "</H3>"
|
||||
#define OPEN_DL_STRING "<DL>"
|
||||
#define CLOSE_DL_STRING "</DL>"
|
||||
#define DT_STRING "<DT>"
|
||||
#define PAR_STRING "<P>"
|
||||
#define DD_STRING "<DD>"
|
||||
|
||||
#define IN_TITLE 1
|
||||
#define IN_H3 5
|
||||
#define IN_ITEM_TITLE 7
|
||||
#define IN_ITEM_DESCRIPTION 9
|
||||
|
||||
|
||||
|
||||
/* bmk2mcf.c function prototypes */
|
||||
|
||||
|
||||
|
||||
RDF_Resource createSeparator(void);
|
||||
RDF_Resource createContainer (char* id);
|
||||
char * resourceDescription (RDF rdf, RDF_Resource r);
|
||||
char * resourceLastVisitDate (RDF rdf, RDF_Resource r);
|
||||
char * resourceLastModifiedDate (RDF rdf, RDF_Resource r);
|
||||
void parseNextBkBlob (RDFFile f, char* blob, int32 size);
|
||||
void parseNextBkToken (RDFFile f, char* token);
|
||||
void addDescription (RDFFile f, RDF_Resource r, char* token);
|
||||
void bkStateTransition (RDFFile f, char* token);
|
||||
void newFolderBkItem(RDFFile f, char* token);
|
||||
void newLeafBkItem (RDFFile f, char* token);
|
||||
char * numericDate(char *url);
|
||||
void HT_WriteOutAsBookmarks1 (RDF rdf, PRFileDesc *fp, RDF_Resource u, RDF_Resource top, int indent);
|
||||
void flushBookmarks();
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
114
mozilla/modules/rdf/src/che2rdf.c
Normal file
@@ -0,0 +1,114 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
/* We need to define a new class of urls for cache objects.
|
||||
e.g., cache:<something here>
|
||||
|
||||
The url for the rdf datastore corresponding to the cache
|
||||
is rdf:cache.
|
||||
|
||||
The Cache Schema.
|
||||
The cache consists of a hierarchy of objects. The standard
|
||||
hierarchy relation (RDF_parent). In addition, each object
|
||||
may have the following properties.
|
||||
lastAccess
|
||||
lastModified
|
||||
|
||||
container cache objects start with cache:container ...
|
||||
|
||||
*/
|
||||
|
||||
|
||||
RDFT gCacheStore = NULL;
|
||||
|
||||
RDFT MakeCacheStore (char* url) {
|
||||
if (startsWith("rdf:cache", url)) {
|
||||
if (gCacheStore != NULL) {
|
||||
return gCacheStore;
|
||||
} else {
|
||||
RDF_Translator ntr = (RDF_Translator)getMem(sizeof(RDF_TranslatorStruct));
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = NULL;
|
||||
ntr->getSlotValue = cacheGetSlotValue;
|
||||
ntr->getSlotValues = cacheGetSlotValues;
|
||||
ntr->hasAssertion = cacheHasAssertion;
|
||||
ntr->nextValue = cacheNextValue;
|
||||
ntr->disposeCursor = cacheDisposeCursor;
|
||||
gCacheStore = ntr;
|
||||
return ntr;
|
||||
}
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
PRBool
|
||||
cacheHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv) {
|
||||
if ((resourceType(u) == CACHE_RT) && tv) {
|
||||
/*e.g., u->id = cache:http://www.netscape.com/
|
||||
s = gWebData->RDF_size
|
||||
v = 1000
|
||||
type = RDF_INT_TYPE
|
||||
return true if the cache object corresponding to u has a size of 1000
|
||||
e.g., u->id = cache:http://www.netscape.com/
|
||||
s = gCoreVocab->RDF_parent
|
||||
type = RDF_RESOURCE_TYPE
|
||||
v-> = "cache:container:MemoryCache"
|
||||
*/
|
||||
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RDF_Cursor cacheGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv) {
|
||||
if ((resourceType(u) == CACHE_RT) && tv && (s == gCoreVocab->RDF_parent) && inversep) {
|
||||
RDF_Cursor c;
|
||||
c = (RDF_Cursor) getMem(sizeof(RDF_CursorStruc));
|
||||
c->u = u;
|
||||
c->count = 0;
|
||||
c->pdata = NULL;
|
||||
c->type = type;
|
||||
return c;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
void* cacheNextValue (RDFT rdf, RDF_Cursor c) {
|
||||
"return the next value, update count, return NUll when there are no more.
|
||||
the children are nodes. to create a new node, call RDF_Create(url, 1);
|
||||
If something is a container, after getting the object, do setContainerp(r, 1);"
|
||||
}
|
||||
|
||||
RDF_Error cacheDisposeCursor (RDFT rdf, RDF_Cursor c) {
|
||||
"dispose it. c could be NULL"
|
||||
}
|
||||
|
||||
|
||||
void* cacheGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv) {
|
||||
if ("willing to answer this") {
|
||||
return the value;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
284
mozilla/modules/rdf/src/columns.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file synthesizes default columns for a given node.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "columns.h"
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
|
||||
if (!containerp(u) || (s != gNavCenter->RDF_Column) || (inversep) ||
|
||||
(!tv) || (type != RDF_RESOURCE_TYPE))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
if ((c = (RDF_Cursor)getMem(sizeof(struct RDF_CursorStruct))) != NULL)
|
||||
{
|
||||
c->u = u;
|
||||
c->value = NULL;
|
||||
c->count = 0;
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type,
|
||||
PRBool inversep, PRBool tv)
|
||||
{
|
||||
void *val = NULL;
|
||||
|
||||
if (u == NULL) return(NULL);
|
||||
|
||||
if ((s == gCoreVocab->RDF_name) && (type == RDF_STRING_TYPE)
|
||||
&& (!inversep) && (tv))
|
||||
{
|
||||
#ifdef XXX
|
||||
if (u == gCoreVocab->RDF_name) val = copyString(XP_GetString(RDF_NAME_STR));
|
||||
else if (u == gNavCenter->RDF_URLShortcut) val = copyString(XP_GetString(RDF_SHORTCUT_STR));
|
||||
else if (u == gWebData->RDF_URL) val = copyString(XP_GetString(RDF_URL_STR));
|
||||
else if (u == gWebData->RDF_description) val = copyString(XP_GetString(RDF_DESCRIPTION_STR));
|
||||
else if (u == gWebData->RDF_firstVisitDate) val = copyString(XP_GetString(RDF_FIRST_VISIT_STR));
|
||||
else if (u == gWebData->RDF_lastVisitDate) val = copyString(XP_GetString(RDF_LAST_VISIT_STR));
|
||||
else if (u == gWebData->RDF_numAccesses) val = copyString(XP_GetString(RDF_NUM_ACCESSES_STR));
|
||||
else if (u == gWebData->RDF_creationDate) val = copyString(XP_GetString(RDF_CREATED_ON_STR));
|
||||
else if (u == gWebData->RDF_lastModifiedDate) val = copyString(XP_GetString(RDF_LAST_MOD_STR));
|
||||
else if (u == gWebData->RDF_size) val = copyString(XP_GetString(RDF_SIZE_STR));
|
||||
else if (u == gNavCenter->RDF_bookmarkAddDate) val = copyString(XP_GetString(RDF_ADDED_ON_STR));
|
||||
#endif
|
||||
}
|
||||
else if ((s == gNavCenter->RDF_ColumnDataType) &&
|
||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
||||
{
|
||||
if (u == gNavCenter->RDF_bookmarkAddDate ||
|
||||
u == gWebData->RDF_firstVisitDate ||
|
||||
u == gWebData->RDF_lastVisitDate ||
|
||||
u == gWebData->RDF_lastModifiedDate ||
|
||||
u == gWebData->RDF_creationDate)
|
||||
{
|
||||
val = (void *)HT_COLUMN_STRING;
|
||||
}
|
||||
else if (u == gWebData->RDF_size ||
|
||||
u == gWebData->RDF_numAccesses ||
|
||||
u == gNavCenter->cookieDomain ||
|
||||
u == gNavCenter->cookieSecure)
|
||||
{
|
||||
val = (void *)HT_COLUMN_INT;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* default to string... XXX wrong thing to do? */
|
||||
val = (void *)HT_COLUMN_STRING;
|
||||
}
|
||||
}
|
||||
else if ((s == gNavCenter->RDF_ColumnWidth) &&
|
||||
(type == RDF_INT_TYPE) && (!inversep) && (tv))
|
||||
{
|
||||
if (u == gCoreVocab->RDF_name) val = (void *)128L;
|
||||
else if (u == gWebData->RDF_URL) val = (void *)200L;
|
||||
else val = (void *)80;
|
||||
}
|
||||
return(val);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ColumnsNextValue (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
void *arc = NULL;
|
||||
|
||||
PR_ASSERT(c != NULL);
|
||||
if (c == NULL) return(NULL);
|
||||
|
||||
switch( resourceType(c->u) )
|
||||
{
|
||||
case RDF_RT:
|
||||
if ((c->u == gNavCenter->RDF_Sitemaps) || (c->u == gNavCenter->RDF_Mail))
|
||||
{
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
}
|
||||
}
|
||||
else do
|
||||
{
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1:
|
||||
if ((idenEqual(c->u, gNavCenter->RDF_BookmarkFolderCategory)) ||
|
||||
((!startsWith("http://", resourceID(c->u))) && endsWith(".rdf", resourceID(c->u))))
|
||||
{
|
||||
arc = gNavCenter->RDF_URLShortcut;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* disallow shortcuts from external RDF graphs, so skip to next column */
|
||||
arc = NULL;
|
||||
++(c->count);
|
||||
}
|
||||
break;
|
||||
|
||||
case 2: arc = gWebData->RDF_URL; break;
|
||||
case 3: arc = gWebData->RDF_description; break;
|
||||
case 4: arc = gWebData->RDF_keyword; break;
|
||||
case 5: arc = gNavCenter->RDF_bookmarkAddDate; break;
|
||||
case 6: arc = gWebData->RDF_lastVisitDate; break;
|
||||
case 7: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
case 8: arc = gNavCenter->pos; break;
|
||||
}
|
||||
} while ((c->count <= 6) && (arc == NULL));
|
||||
break;
|
||||
|
||||
|
||||
|
||||
case HISTORY_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_firstVisitDate; break;
|
||||
case 3: arc = gWebData->RDF_lastVisitDate; break;
|
||||
case 4: arc = NULL; break;
|
||||
case 5: arc = gWebData->RDF_numAccesses; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case COOKIE_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gNavCenter->cookieHost; break;
|
||||
case 2: arc = gNavCenter->cookiePath; break;
|
||||
case 3: arc = gNavCenter->cookieValue; break;
|
||||
case 4: arc = gNavCenter->cookieExpires; break;
|
||||
case 5: arc = gNavCenter->cookieDomain; break;
|
||||
case 6: arc = gNavCenter->cookieSecure; break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case FTP_RT:
|
||||
case ES_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_description; break;
|
||||
case 3: arc = gWebData->RDF_size; break;
|
||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LFS_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
case 2: arc = gWebData->RDF_description; break;
|
||||
case 3: arc = gWebData->RDF_size; break;
|
||||
case 4: arc = gWebData->RDF_lastModifiedDate; break;
|
||||
case 5: arc = gWebData->RDF_creationDate; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case LDAP_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case PM_RT:
|
||||
case IM_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gWebData->RDF_URL; break;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEARCH_RT:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
case 1: arc = gNavCenter->RDF_URLShortcut; break;
|
||||
case 2: arc = gWebData->RDF_URL; break;
|
||||
case 3: arc = gWebData->RDF_description; break;
|
||||
case 4: arc = gWebData->RDF_keyword; break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
switch(c->count)
|
||||
{
|
||||
case 0: arc = gCoreVocab->RDF_name; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
++(c->count);
|
||||
return(arc);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL)
|
||||
{
|
||||
freeMem(c);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeColumnStore (char* url)
|
||||
{
|
||||
RDFT ntr = NULL;
|
||||
|
||||
if (strstr(url, "rdf:columns"))
|
||||
{
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
||||
{
|
||||
ntr->getSlotValues = ColumnsGetSlotValues;
|
||||
ntr->getSlotValue = ColumnsGetSlotValue;
|
||||
ntr->nextValue = ColumnsNextValue;
|
||||
ntr->disposeCursor = ColumnsDisposeCursor;
|
||||
ntr->url = copyString(url);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return(ntr);
|
||||
}
|
||||
48
mozilla/modules/rdf/src/columns.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_COLUMNS_H_
|
||||
#define _RDF_COLUMNS_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "htrdf.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
|
||||
/* columns.c data structures */
|
||||
|
||||
extern int RDF_NAME_STR, RDF_SHORTCUT_STR, RDF_URL_STR, RDF_DESCRIPTION_STR;
|
||||
extern int RDF_FIRST_VISIT_STR, RDF_LAST_VISIT_STR, RDF_NUM_ACCESSES_STR;
|
||||
extern int RDF_CREATED_ON_STR, RDF_LAST_MOD_STR, RDF_SIZE_STR, RDF_ADDED_ON_STR;
|
||||
|
||||
|
||||
/* columns.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDF_Cursor ColumnsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ColumnsGetSlotValue(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ColumnsNextValue (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Error ColumnsDisposeCursor (RDFT rdf, RDF_Cursor c);
|
||||
RDFT MakeColumnStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
574
mozilla/modules/rdf/src/comwrap.cpp
Normal file
@@ -0,0 +1,574 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFDataSource.h"
|
||||
#include "nsIRDFDataBase.h"
|
||||
#include "nsIRDFObserver.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIRDFCursor.h"
|
||||
|
||||
#include "nspr.h"
|
||||
#include "plhash.h"
|
||||
|
||||
PR_BEGIN_EXTERN_C
|
||||
PR_PUBLIC_API(void) _comwrap_NotificationCB(RDF_Event event, void* pdata);
|
||||
PR_END_EXTERN_C
|
||||
|
||||
class rdfDataBaseWrapper;
|
||||
class rdfCursorWrapper;
|
||||
class rdfServiceWrapper;
|
||||
class rdfServiceFactory;
|
||||
|
||||
class rdfDatabaseWrapper : public nsIRDFDataBase {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfDatabaseWrapper(RDF r);
|
||||
virtual ~rdfDatabaseWrapper();
|
||||
|
||||
/* nsIRDFDataSource methods: */
|
||||
|
||||
NS_METHOD GetName(const RDF_String* name /* out */ );
|
||||
|
||||
NS_METHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */);
|
||||
|
||||
NS_METHOD GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
|
||||
NS_METHOD GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */);
|
||||
|
||||
NS_METHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */);
|
||||
|
||||
NS_METHOD GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */);
|
||||
|
||||
NS_METHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */);
|
||||
|
||||
NS_METHOD GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */);
|
||||
|
||||
NS_METHOD Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv = PR_TRUE);
|
||||
|
||||
NS_METHOD Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target);
|
||||
|
||||
NS_METHOD HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv,
|
||||
PRBool* hasAssertion /* out */);
|
||||
|
||||
NS_METHOD AddObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask type = RDF_ANY_NOTIFY);
|
||||
|
||||
NS_METHOD RemoveObserver(nsIRDFObserver *n,
|
||||
RDF_EventMask = RDF_ANY_NOTIFY);
|
||||
|
||||
NS_METHOD ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */);
|
||||
|
||||
NS_METHOD ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */);
|
||||
|
||||
NS_METHOD Flush();
|
||||
|
||||
/* nsIRDFDataBase methods: */
|
||||
NS_METHOD AddDataSource(nsIRDFDataSource* dataSource);
|
||||
|
||||
NS_METHOD RemoveDataSource(nsIRDFDataSource* dataSource);
|
||||
|
||||
NS_METHOD GetDataSource(RDF_String url,
|
||||
nsIRDFDataSource **source /* out */ );
|
||||
|
||||
NS_METHOD DeleteAllArcs(RDF_Resource resource);
|
||||
|
||||
private:
|
||||
RDF mRDF;
|
||||
|
||||
PLHashTable* mpObserverMap;
|
||||
};
|
||||
|
||||
class rdfCursorWrapper : public nsIRDFCursor {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfCursorWrapper(RDF_Cursor c);
|
||||
virtual ~rdfCursorWrapper();
|
||||
|
||||
NS_METHOD HasElements(PRBool& hasElements);
|
||||
|
||||
NS_METHOD Next(RDF_NodeStruct& n);
|
||||
|
||||
private:
|
||||
RDF_Cursor mCursor;
|
||||
};
|
||||
|
||||
class rdfServiceWrapper : public nsIRDFService {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CreateDatabase(const RDF_String* url,
|
||||
nsIRDFDataBase** db);
|
||||
|
||||
};
|
||||
|
||||
class rdfServiceFactory : public nsIFactory {
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
rdfServiceFactory();
|
||||
virtual ~rdfServiceFactory();
|
||||
|
||||
NS_METHOD CreateInstance(nsISupports *aOuter,
|
||||
REFNSIID anIID,
|
||||
void **aResult);
|
||||
|
||||
NS_METHOD LockFactory(PRBool aLock);
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
rdfDataBaseWrapper:
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfDatabaseWrapper, NS_IRDFDATABASE_IID )
|
||||
|
||||
rdfDatabaseWrapper::rdfDatabaseWrapper(RDF r) : mRDF(r)
|
||||
{
|
||||
mpObserverMap = PL_NewHashTable( 100,
|
||||
NULL, // XXX isn't there are hash fn for pointers???
|
||||
PL_CompareValues,
|
||||
PL_CompareValues,
|
||||
0,
|
||||
0 );
|
||||
|
||||
PR_ASSERT( mpObserverMap );
|
||||
#ifdef XXX
|
||||
if( !mpObserverMap ) // XXX just like 'new' failing on this object?
|
||||
throw bad_alloc("rdf: unable to allocate observer map" );
|
||||
#endif
|
||||
}
|
||||
|
||||
rdfDatabaseWrapper::~rdfDatabaseWrapper()
|
||||
{
|
||||
PL_HashTableDestroy( mpObserverMap );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetName(const RDF_String* name /* out */ )
|
||||
{
|
||||
PR_ASSERT( PR_FALSE );
|
||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Resource *source /* out */)
|
||||
{
|
||||
PR_ASSERT( target && source );
|
||||
*source = (RDF_Resource) RDF_GetSlotValue( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
PR_TRUE,
|
||||
PR_TRUE );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSource(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_Resource *source /* out */)
|
||||
{
|
||||
*source = (RDF_Resource) RDF_GetSlotValue( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
PR_TRUE,
|
||||
tv );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
{
|
||||
return GetSources(target,arcLabel,PR_TRUE,sources);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetSources(RDF_Node target,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
nsIRDFCursor **sources /* out */)
|
||||
{
|
||||
PR_ASSERT( sources );
|
||||
if( 0 == sources )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*sources = 0;
|
||||
|
||||
RDF_Cursor c = RDF_GetSources( mRDF,
|
||||
target->value.r,
|
||||
arcLabel,
|
||||
RDF_RESOURCE_TYPE, // anything else makes no sense
|
||||
tv );
|
||||
|
||||
if( c ) {
|
||||
*sources = new rdfCursorWrapper( c );
|
||||
(*sources)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
RDF_NodeStruct& target /* in/out */)
|
||||
{
|
||||
return GetTarget(source,arcLabel,targetType,PR_TRUE,target);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTarget(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
PRBool tv,
|
||||
RDF_NodeStruct& target /* in/out */)
|
||||
{
|
||||
PR_ASSERT( targetType != RDF_ANY_TYPE ); // not ready to support this yet
|
||||
|
||||
void* value = RDF_GetSlotValue( mRDF,
|
||||
target.value.r,
|
||||
arcLabel,
|
||||
targetType, // anything else makes no sense
|
||||
PR_FALSE,
|
||||
tv );
|
||||
|
||||
target.type = targetType;
|
||||
target.value.r = (RDF_Resource) value; // reasonable? XXX
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */)
|
||||
{
|
||||
return GetTargets(source,arcLabel,PR_TRUE,targetType,targets);
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::GetTargets(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
PRBool tv,
|
||||
RDF_ValueType targetType,
|
||||
nsIRDFCursor **targets /* out */)
|
||||
{
|
||||
PR_ASSERT( targets );
|
||||
if( 0 == targets )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*targets = 0;
|
||||
|
||||
RDF_Cursor c = RDF_GetTargets( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
targetType,
|
||||
tv );
|
||||
|
||||
if( c ) {
|
||||
*targets = new rdfCursorWrapper( c );
|
||||
(*targets)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Assert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool tv)
|
||||
{
|
||||
PRBool b = tv ? RDF_Assert( mRDF, source, arcLabel, (void*)target->value.r, target->type ) :
|
||||
RDF_AssertFalse( mRDF, source, arcLabel, (void*)target->value.r, target->type );
|
||||
|
||||
// XXX
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Unassert(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target)
|
||||
{
|
||||
PRBool b = RDF_Unassert( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
target->value.r,
|
||||
target->type ); // XXX
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::HasAssertion(RDF_Resource source,
|
||||
RDF_Resource arcLabel,
|
||||
RDF_Node target,
|
||||
PRBool truthValue,
|
||||
PRBool* hasAssertion /* out */)
|
||||
{
|
||||
*hasAssertion = RDF_HasAssertion( mRDF,
|
||||
source,
|
||||
arcLabel,
|
||||
target->value.r,
|
||||
target->type,
|
||||
truthValue );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PR_IMPLEMENT(void)
|
||||
_comwrap_NotificationCB(RDF_Event event, void* pdata)
|
||||
{
|
||||
nsIRDFObserver* observer = (nsIRDFObserver*) pdata;
|
||||
// XXX QueryInterface & release??
|
||||
observer->HandleEvent( (nsIRDFDataSource*)pdata, event );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::AddObserver(nsIRDFObserver *observer,
|
||||
RDF_EventMask type)
|
||||
{
|
||||
// XXX event masking does not currently work
|
||||
|
||||
RDF_Notification notification = (RDF_Notification) PL_HashTableLookup( mpObserverMap, observer );
|
||||
if( !notification ) {
|
||||
observer->AddRef();
|
||||
notification = RDF_AddNotifiable( mRDF,
|
||||
_comwrap_NotificationCB,
|
||||
NULL, // XXX
|
||||
observer );
|
||||
PL_HashTableAdd( mpObserverMap,
|
||||
observer,
|
||||
notification );
|
||||
}
|
||||
|
||||
return NS_OK; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::RemoveObserver(nsIRDFObserver *observer,
|
||||
RDF_EventMask type)
|
||||
{
|
||||
|
||||
RDF_Notification notification = (RDF_Notification) PL_HashTableLookup( mpObserverMap, observer );
|
||||
if( !notification )
|
||||
return NS_ERROR_ILLEGAL_VALUE;
|
||||
|
||||
RDF_Error err = RDF_DeleteNotifiable( notification );
|
||||
PR_ASSERT( !err ); // the current implementation never fails!
|
||||
PL_HashTableRemove( mpObserverMap, observer );
|
||||
observer->Release();
|
||||
|
||||
return NS_OK; // XXX
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::ArcLabelsIn(RDF_Node node,
|
||||
nsIRDFCursor **labels /* out */)
|
||||
{
|
||||
PR_ASSERT( labels );
|
||||
if( 0 == labels )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*labels = 0;
|
||||
|
||||
RDF_Cursor c = RDF_ArcLabelsIn( mRDF, node->value.r );
|
||||
|
||||
if( c ) {
|
||||
*labels = new rdfCursorWrapper( c );
|
||||
(*labels)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::ArcLabelsOut(RDF_Resource source,
|
||||
nsIRDFCursor **labels /* out */)
|
||||
{
|
||||
PR_ASSERT( labels );
|
||||
if( 0 == labels )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*labels = 0;
|
||||
|
||||
RDF_Cursor c = RDF_ArcLabelsOut( mRDF, source );
|
||||
|
||||
if( c ) {
|
||||
*labels = new rdfCursorWrapper( c );
|
||||
(*labels)->AddRef();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::Flush()
|
||||
{
|
||||
return NS_ERROR_NOT_IMPLEMENTED; // XXX
|
||||
}
|
||||
|
||||
|
||||
NS_METHOD
|
||||
rdfDatabaseWrapper::DeleteAllArcs(RDF_Resource resource)
|
||||
{
|
||||
return RDF_DeleteAllArcs( mRDF, resource );
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfServiceWrapper: the RDF service singleton
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfServiceWrapper, NS_IRDFSERVICE_IID )
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceWrapper::CreateDatabase(const RDF_String* url_ary,
|
||||
nsIRDFDataBase **db)
|
||||
{
|
||||
PR_ASSERT( 0 != db );
|
||||
if( 0 == db )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
|
||||
*db = 0;
|
||||
|
||||
nsresult result = NS_OK;
|
||||
RDF rdf = RDF_GetDB(url_ary);
|
||||
|
||||
if( 0 == rdf ) {
|
||||
result = RDF_ERROR_UNABLE_TO_CREATE; // XXX this is too wishy-washy
|
||||
} else {
|
||||
*db = new rdfDatabaseWrapper(rdf); // XXX
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfCursorWrapper
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfCursorWrapper, NS_IRDFCURSOR_IID )
|
||||
|
||||
rdfCursorWrapper::rdfCursorWrapper(RDF_Cursor c) : mCursor(c)
|
||||
{
|
||||
}
|
||||
|
||||
rdfCursorWrapper::~rdfCursorWrapper()
|
||||
{
|
||||
RDF_DisposeCursor( mCursor );
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfCursorWrapper::Next(RDF_NodeStruct& next)
|
||||
{
|
||||
next.type = RDF_CursorValueType( mCursor );
|
||||
next.value.r = (RDF_Resource) RDF_NextValue( mCursor );
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
rdfServiceFactory
|
||||
|
||||
*/
|
||||
|
||||
NS_IMPL_ISUPPORTS( rdfServiceFactory, NS_IFACTORY_IID )
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceFactory::CreateInstance( nsISupports *aOuter,
|
||||
REFNSIID aIID,
|
||||
void **aResult )
|
||||
{
|
||||
PR_ASSERT( aResult );
|
||||
if( 0 == aResult )
|
||||
return NS_ERROR_NULL_POINTER;
|
||||
*aResult = 0;
|
||||
|
||||
nsISupports* instance = new rdfServiceWrapper();
|
||||
|
||||
nsresult result = instance->QueryInterface( aIID, aResult );
|
||||
PR_ASSERT( result = NS_OK );
|
||||
|
||||
if( result != NS_OK )
|
||||
delete instance; // wrong interface!
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NS_METHOD
|
||||
rdfServiceFactory::LockFactory(PRBool lock)
|
||||
{
|
||||
PR_ASSERT( PR_FALSE );
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
490
mozilla/modules/rdf/src/es2mcf.c
Normal file
@@ -0,0 +1,490 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements FTP support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "es2mcf.h"
|
||||
#include "glue.h"
|
||||
#include "ht.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/* externs */
|
||||
extern RDF gNCDB;
|
||||
#define ESFTPRT(x) ((resourceType((RDF_Resource)x) == ES_RT) || (resourceType((RDF_Resource)x) == FTP_RT))
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeESFTPStore (char* url)
|
||||
{
|
||||
RDFT ntr = NewRemoteStore(url);
|
||||
ntr->assert = ESAssert;
|
||||
ntr->unassert = ESUnassert;
|
||||
ntr->possiblyAccessFile = ESFTPPossiblyAccessFile;
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if (((resourceType(u) == ES_RT) || (resourceType(u) == FTP_RT)) &&
|
||||
(s == gCoreVocab->RDF_parent) && (containerp(u))) {
|
||||
char* id = resourceID(u);
|
||||
readRDFFile((resourceType(u) == ES_RT ? &id[4] : id), u, false, rdf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
PRBool retVal;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) v)));
|
||||
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ESFTPRT((RDF_Resource)v)) &&
|
||||
(tv) && (containerp((RDF_Resource)v))) {
|
||||
ESAddChild((RDF_Resource)v, u);
|
||||
retVal = PR_TRUE;
|
||||
} else {
|
||||
retVal = PR_FALSE;
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
PRBool retVal;
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) v)));
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ESFTPRT((RDF_Resource)v)) &&
|
||||
(containerp((RDF_Resource)v))) {
|
||||
ESRemoveChild((RDF_Resource)v, u);
|
||||
retVal = PR_TRUE;
|
||||
} else {
|
||||
retVal = PR_FALSE;
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
||||
{
|
||||
RDF_Resource parent = NULL, child = NULL, r;
|
||||
_esFEData *feData;
|
||||
char *newURL, *p;
|
||||
|
||||
feData = (_esFEData *)urls->fe_data;
|
||||
if ((status >= 0) && (feData != NULL))
|
||||
{
|
||||
parent = RDF_GetResource(gNCDB, feData->parent, false);
|
||||
child = RDF_GetResource(gNCDB, feData->child, false);
|
||||
if ((parent != NULL) && (child != NULL))
|
||||
{
|
||||
switch(feData->method)
|
||||
{
|
||||
case URL_POST_METHOD:
|
||||
if (((p = RDF_STRRCHR(resourceID(child), '/')) != NULL) && (*++p != '\0'))
|
||||
{
|
||||
if ((newURL = append2Strings(resourceID(parent), p)) != NULL)
|
||||
{
|
||||
if ((r = RDF_GetResource(gNCDB, newURL, 1)) != NULL)
|
||||
{
|
||||
setContainerp(r, containerp(child));
|
||||
setResourceType(r, resourceType(child));
|
||||
|
||||
remoteStoreAdd(gRemoteStore, r,
|
||||
gCoreVocab->RDF_parent, parent,
|
||||
RDF_RESOURCE_TYPE, 1);
|
||||
}
|
||||
freeMem(newURL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case URL_DELETE_METHOD:
|
||||
remoteStoreRemove(gRemoteStore, child,
|
||||
gCoreVocab->RDF_parent, parent,
|
||||
RDF_RESOURCE_TYPE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (status < 0)
|
||||
{
|
||||
if ((cx != NULL) && (urls != NULL) && (urls->error_msg != NULL))
|
||||
{
|
||||
FE_Alert(cx, urls->error_msg);
|
||||
}
|
||||
}
|
||||
if (feData != NULL)
|
||||
{
|
||||
esFreeFEData(feData);
|
||||
}
|
||||
NET_FreeURLStruct (urls);
|
||||
}
|
||||
|
||||
|
||||
|
||||
char *
|
||||
nativeFilename(char *filename)
|
||||
{
|
||||
char *newName = NULL, *temp;
|
||||
int x = 0;
|
||||
|
||||
if (filename == NULL) return(NULL);
|
||||
if ((newName = unescapeURL(filename)) != NULL)
|
||||
{
|
||||
if ((temp = convertFileURLToNSPRCopaceticPath(newName)) != NULL)
|
||||
{
|
||||
temp = copyString(temp);
|
||||
}
|
||||
freeMem(newName);
|
||||
newName = temp;
|
||||
#ifdef XP_WIN
|
||||
if (newName != NULL)
|
||||
{
|
||||
while (newName[x] != '\0')
|
||||
{
|
||||
if (newName[x] == '/')
|
||||
{
|
||||
newName[x] = '\\';
|
||||
}
|
||||
++x;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return(newName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
_esFEData *
|
||||
esMakeFEData(RDF_Resource parent, RDF_Resource child, int method)
|
||||
{
|
||||
_esFEData *feData;
|
||||
|
||||
if ((feData = (_esFEData *)XP_ALLOC(3*sizeof(char *))) != NULL)
|
||||
{
|
||||
feData->parent = copyString(resourceID(parent));
|
||||
feData->child = copyString(resourceID(child));
|
||||
feData->method = method;
|
||||
}
|
||||
return(feData);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
esFreeFEData(_esFEData *feData)
|
||||
{
|
||||
if (feData != NULL)
|
||||
{
|
||||
if (feData->parent) freeMem(feData->parent);
|
||||
if (feData->child) freeMem(feData->child);
|
||||
freeMem(feData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** go tell the directory that child got added to parent **/
|
||||
void
|
||||
ESAddChild (RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
void *feData, **files_to_post = NULL;
|
||||
|
||||
if ((urls = NET_CreateURLStruct(resourceID(parent), NET_SUPER_RELOAD)) != NULL)
|
||||
{
|
||||
feData = (void *)esMakeFEData(parent, child, URL_POST_METHOD);
|
||||
if ((files_to_post = (char **)XP_ALLOC(2*sizeof(char *))) != NULL)
|
||||
{
|
||||
files_to_post[0] = nativeFilename(resourceID(child));
|
||||
files_to_post[1] = NULL;
|
||||
}
|
||||
if ((feData != NULL) && (files_to_post != NULL))
|
||||
{
|
||||
urls->files_to_post = (void *)files_to_post;
|
||||
urls->post_to = NULL;
|
||||
urls->method = URL_POST_METHOD;
|
||||
urls->fe_data = (void *)feData;
|
||||
NET_GetURL(urls, FO_PRESENT,
|
||||
(MWContext *)gRDFMWContext(NULL),
|
||||
es_GetUrlExitFunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (feData != NULL)
|
||||
{
|
||||
esFreeFEData(feData);
|
||||
}
|
||||
if (files_to_post != NULL)
|
||||
{
|
||||
if (files_to_post[0] != NULL) freeMem(files_to_post[0]);
|
||||
XP_FREE(files_to_post);
|
||||
}
|
||||
NET_FreeURLStruct(urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** remove the child from the directory **/
|
||||
void
|
||||
ESRemoveChild (RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
void *feData;
|
||||
|
||||
if ((urls = NET_CreateURLStruct(resourceID(child), NET_SUPER_RELOAD)) != NULL)
|
||||
{
|
||||
feData = (void *)esMakeFEData(parent, child, URL_DELETE_METHOD);
|
||||
if (feData != NULL)
|
||||
{
|
||||
urls->method = URL_DELETE_METHOD;
|
||||
urls->fe_data = (void *)feData;
|
||||
NET_GetURL(urls, FO_PRESENT,
|
||||
(MWContext *)gRDFMWContext(NULL),
|
||||
es_GetUrlExitFunc);
|
||||
}
|
||||
else
|
||||
{
|
||||
NET_FreeURLStruct(urls);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseNextESFTPLine (RDFFile f, char* line)
|
||||
{
|
||||
PRBool directoryp;
|
||||
RDF_Resource ru;
|
||||
char *token, *url;
|
||||
int16 loop, tokenNum = 0;
|
||||
int32 val;
|
||||
|
||||
if (f->fileType != FTP_RT && f->fileType != ES_RT) return;
|
||||
|
||||
/* work around bug where linefeeds are actually encoded as %0A */
|
||||
if (endsWith("%0A", line)) line[RDF_STRLEN(line)-3] = '\0';
|
||||
|
||||
if ((token = strtok(line, " ")) != NULL)
|
||||
{
|
||||
/* skip 1st token (the numeric command) */
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
|
||||
if (startsWith("200:", line))
|
||||
{
|
||||
while (token != NULL)
|
||||
{
|
||||
while ((token != NULL) && (tokenNum < RDF_MAX_NUM_FILE_TOKENS))
|
||||
{
|
||||
if (!RDF_STRCMP(token, "Filename"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gCoreVocab->RDF_name;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "Content-Length"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_size;
|
||||
f->tokens[f->numFileTokens].type = RDF_INT_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "File-type"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_description;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
else if (!RDF_STRCMP(token, "Last-Modified"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = gWebData->RDF_lastModifiedDate;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
/*
|
||||
else if (!RDF_STRCMP(token, "Permissions"))
|
||||
{
|
||||
f->tokens[f->numFileTokens].token = NULL;
|
||||
f->tokens[f->numFileTokens].type = RDF_STRING_TYPE;
|
||||
f->tokens[f->numFileTokens].tokenNum = tokenNum;
|
||||
++(f->numFileTokens);
|
||||
}
|
||||
*/
|
||||
++tokenNum;
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (startsWith("201:", line))
|
||||
{
|
||||
directoryp = false;
|
||||
while (token != NULL)
|
||||
{
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
if (tokenNum == f->tokens[loop].tokenNum)
|
||||
{
|
||||
f->tokens[loop].data = strdup(token);
|
||||
if (f->tokens[loop].token == gWebData->RDF_description)
|
||||
{
|
||||
if (startsWith("Directory", token) ||
|
||||
startsWith("Sym-Directory", token))
|
||||
{
|
||||
directoryp = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
++tokenNum;
|
||||
token = strtok(NULL, " \t");
|
||||
}
|
||||
|
||||
ru = NULL;
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
/* find name, create resource from it */
|
||||
|
||||
if (f->tokens[loop].token == gCoreVocab->RDF_name)
|
||||
{
|
||||
if (resourceType(f->top) == ES_RT)
|
||||
{
|
||||
url = PR_smprintf("nes:%s%s%s", f->url, f->tokens[loop].data, (directoryp) ? "/":"");
|
||||
}
|
||||
else
|
||||
{
|
||||
url = PR_smprintf("%s%s%s", f->url, f->tokens[loop].data, (directoryp) ? "/":"");
|
||||
}
|
||||
if (url != NULL)
|
||||
{
|
||||
if ((ru = RDF_GetResource(NULL, url, 1)) != NULL)
|
||||
{
|
||||
setResourceType(ru, resourceType(f->top));
|
||||
if (directoryp == true)
|
||||
{
|
||||
setContainerp(ru, 1);
|
||||
}
|
||||
XP_FREE(url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ru != NULL)
|
||||
{
|
||||
for (loop=0; loop<f->numFileTokens; loop++)
|
||||
{
|
||||
if (f->tokens[loop].data != NULL)
|
||||
{
|
||||
switch(f->tokens[loop].type)
|
||||
{
|
||||
case RDF_STRING_TYPE:
|
||||
addSlotValue(f, ru, f->tokens[loop].token,
|
||||
unescapeURL(f->tokens[loop].data),
|
||||
f->tokens[loop].type, NULL);
|
||||
break;
|
||||
|
||||
case RDF_INT_TYPE:
|
||||
if (directoryp == false)
|
||||
{
|
||||
sscanf(f->tokens[loop].data, "%lu", &val);
|
||||
if (val != 0)
|
||||
{
|
||||
addSlotValue(f, ru, f->tokens[loop].token,
|
||||
(void *)val, f->tokens[loop].type, NULL);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
addSlotValue(f, ru, gCoreVocab->RDF_parent, f->top, RDF_RESOURCE_TYPE, NULL);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
parseNextESFTPBlob(NET_StreamClass *stream, char* blob, int32 size)
|
||||
{
|
||||
RDFFile f;
|
||||
int32 n, last, m;
|
||||
n = last = 0;
|
||||
|
||||
f = (RDFFile)stream->data_object;
|
||||
if (f == NULL || size < 0) {
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
|
||||
while (n < size) {
|
||||
char c = blob[n];
|
||||
m = 0;
|
||||
memset(f->line, '\0', f->lineSize);
|
||||
if (f->holdOver[0] != '\0') {
|
||||
memcpy(f->line, f->holdOver, RDF_STRLEN(f->holdOver));
|
||||
m = RDF_STRLEN(f->holdOver);
|
||||
memset(f->holdOver, '\0', RDF_BUF_SIZE);
|
||||
}
|
||||
while ((m < f->lineSize) && (c != '\r') && (c != '\n') && (n < size)) {
|
||||
f->line[m] = c;
|
||||
m++;
|
||||
n++;
|
||||
c = blob[n];
|
||||
}
|
||||
n++;
|
||||
if (m > 0) {
|
||||
if ((c == '\n') || (c == '\r')) {
|
||||
last = n;
|
||||
parseNextESFTPLine(f, f->line);
|
||||
} else if (size > last) {
|
||||
memcpy(f->holdOver, f->line, m);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(size);
|
||||
}
|
||||
67
mozilla/modules/rdf/src/es2mcf.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_ES2MCF_H_
|
||||
#define _RDF_ES2MCF_H_
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "net.h"
|
||||
|
||||
|
||||
|
||||
/* es2mcf.c data structures and defines */
|
||||
|
||||
typedef struct {
|
||||
char *parent;
|
||||
char *child;
|
||||
int method;
|
||||
} _esFEData;
|
||||
|
||||
|
||||
|
||||
/* es2mcf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
RDFT MakeESFTPStore (char* url);
|
||||
_esFEData * esMakeFEData(RDF_Resource parent, RDF_Resource child, int method);
|
||||
void esFreeFEData(_esFEData *feData);
|
||||
void ESFTPPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep) ;
|
||||
RDF_Error ESInit (RDFT ntr);
|
||||
PRBool ESFTPRT (RDF_Resource u);
|
||||
PRBool ESAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool ESUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool ESHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * ESGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor ESGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * ESNextValue (RDFT mcf, RDF_Cursor c);
|
||||
RDF_Error ESDisposeCursor (RDFT mcf, RDF_Cursor c);
|
||||
void es_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
||||
char * nativeFilename(char *filename);
|
||||
void ESAddChild (RDF_Resource parent, RDF_Resource child);
|
||||
void ESRemoveChild (RDF_Resource parent, RDF_Resource child);
|
||||
void possiblyAccessES(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
void parseNextESFTPLine (RDFFile f, char* line);
|
||||
int parseNextESFTPBlob(NET_StreamClass *stream, char* blob, int32 size);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
||||
372
mozilla/modules/rdf/src/find2rdf.c
Normal file
@@ -0,0 +1,372 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements Find support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "find2rdf.h"
|
||||
|
||||
/* globals */
|
||||
static RDFT gRDFFindDB = NULL;
|
||||
|
||||
|
||||
|
||||
void
|
||||
parseResourceIntoFindTokens(RDF_Resource u, findTokenStruct *tokens)
|
||||
{
|
||||
char *id, *token, *value;
|
||||
int loop;
|
||||
|
||||
if ((id = copyString(resourceID(u) + RDF_STRLEN("find:"))) != NULL)
|
||||
{
|
||||
/* parse ID, build up token list */
|
||||
if ((token = strtok(id, "&")) != NULL)
|
||||
{
|
||||
while (token != NULL)
|
||||
{
|
||||
if ((value = strstr(token, "=")) != NULL)
|
||||
{
|
||||
*value++ = '\0';
|
||||
}
|
||||
for (loop=0; tokens[loop].token != NULL; loop++)
|
||||
{
|
||||
if (!RDF_STRCMP(token, tokens[loop].token))
|
||||
{
|
||||
tokens[loop].value = copyString(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
token = strtok(NULL, "&");
|
||||
}
|
||||
}
|
||||
freeMem(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
parseFindURL(RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
RDF_Resource searchOn = NULL, matchOn = NULL;
|
||||
int loop;
|
||||
findTokenStruct tokens[5];
|
||||
|
||||
/* build up a token list */
|
||||
tokens[0].token = "location"; tokens[0].value = NULL;
|
||||
tokens[1].token = "attribute"; tokens[1].value = NULL;
|
||||
tokens[2].token = "method"; tokens[2].value = NULL;
|
||||
tokens[3].token = "value"; tokens[3].value = NULL;
|
||||
tokens[4].token = NULL; tokens[4].value = NULL;
|
||||
|
||||
parseResourceIntoFindTokens(u, tokens);
|
||||
|
||||
if ((tokens[1].value != NULL) && (tokens[3].value != NULL))
|
||||
{
|
||||
if ((searchOn = RDF_GetResource(NULL, tokens[1].value, 0)) != NULL)
|
||||
{
|
||||
if ((matchOn = RDF_GetResource(NULL, tokens[2].value, 0)) == NULL)
|
||||
{
|
||||
matchOn = gCoreVocab->RDF_substring;
|
||||
}
|
||||
if ((c = getMem(sizeof(struct RDF_CursorStruct))) != NULL)
|
||||
{
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->tv = tv;
|
||||
c->inversep = inversep;
|
||||
c->count = 0;
|
||||
/* Note: need to copy value string [its a local variable] */
|
||||
c->pdata = (void *)RDF_Find(searchOn, matchOn,
|
||||
copyString(tokens[3].value), RDF_STRING_TYPE);
|
||||
if (c->pdata == NULL)
|
||||
{
|
||||
freeMem(c);
|
||||
c = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* free values in token list */
|
||||
for (loop=0; tokens[loop].token != NULL; loop++)
|
||||
{
|
||||
if (tokens[loop].value != NULL)
|
||||
{
|
||||
freeMem(tokens[loop].value);
|
||||
tokens[loop].value = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
FindGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
PRBool passThru = PR_TRUE;
|
||||
|
||||
if ((((s == gCoreVocab->RDF_child) && (!inversep)) ||
|
||||
((s == gCoreVocab->RDF_parent) && (inversep))) &&
|
||||
(type == RDF_RESOURCE_TYPE) && (tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(u)))
|
||||
{
|
||||
passThru = PR_FALSE;
|
||||
c = parseFindURL(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
c = remoteStoreGetSlotValues(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
findNextURL(RDF_Cursor c)
|
||||
{
|
||||
RDF_Resource r = NULL;
|
||||
PRBool valid = PR_FALSE;
|
||||
|
||||
do
|
||||
{
|
||||
if ((r = (RDF_Resource)RDF_NextValue(c)) != NULL)
|
||||
{
|
||||
if (strstr(resourceID(r), ":"))
|
||||
{
|
||||
if ((!startsWith("find:", resourceID(r))) &&
|
||||
(!startsWith("NC:", resourceID(r))) &&
|
||||
(!startsWith("Command:", resourceID(r))))
|
||||
{
|
||||
valid = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while((r != NULL) && (valid == PR_FALSE));
|
||||
return((void *)r);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
FindNextValue(RDFT rdf, RDF_Cursor c)
|
||||
{
|
||||
PRBool passThru = PR_TRUE;
|
||||
void *retVal = NULL;
|
||||
|
||||
PR_ASSERT(c != NULL);
|
||||
if (c == NULL) return(NULL);
|
||||
|
||||
if ((c->u != NULL) && (((c->s == gCoreVocab->RDF_child) && (!(c->inversep))) ||
|
||||
((c->s == gCoreVocab->RDF_parent) && (c->inversep))) &&
|
||||
(c->type == RDF_RESOURCE_TYPE) && (c->tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(c->u)))
|
||||
{
|
||||
if (c->pdata != NULL)
|
||||
{
|
||||
passThru = PR_FALSE;
|
||||
retVal = findNextURL((RDF_Cursor)(c->pdata));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
retVal = remoteStoreNextValue(rdf, c);
|
||||
}
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
FindGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s,
|
||||
RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
void *retVal = NULL;
|
||||
PRBool passThru = PR_TRUE;
|
||||
|
||||
if ((startsWith("find:", resourceID(u))) && (s == gCoreVocab->RDF_name))
|
||||
{
|
||||
/* DebugStr("\p FindGetSlotValue on name"); */
|
||||
}
|
||||
|
||||
if (passThru == PR_TRUE)
|
||||
{
|
||||
retVal = remoteStoreGetSlotValue(rdf, u, s, type, inversep, tv);
|
||||
}
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char*) retVal)));
|
||||
return(retVal);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
FindPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
RDF_Resource r;
|
||||
|
||||
if ((startsWith("find:", resourceID(u))) && (containerp(u) &&
|
||||
(((s == gCoreVocab->RDF_parent) && (inversep)) ||
|
||||
((s == gCoreVocab->RDF_child) && (!inversep))) ))
|
||||
{
|
||||
if ((c = FindGetSlotValues (rdf, u, s, RDF_RESOURCE_TYPE, inversep, PR_TRUE)) != NULL)
|
||||
{
|
||||
while((r = (RDF_Resource)FindNextValue(rdf, c)) != NULL)
|
||||
{
|
||||
if (!remoteStoreHasAssertion (rdf, r, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE, PR_TRUE))
|
||||
{
|
||||
remoteStoreAdd(rdf, r, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
RDF_DisposeCursor(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
FindDisposeCursor(RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
RDF_Error err = noRDFErr;
|
||||
char *value;
|
||||
|
||||
if (c != NULL)
|
||||
{
|
||||
if ((((c->s == gCoreVocab->RDF_child) && (!(c->inversep))) ||
|
||||
((c->s == gCoreVocab->RDF_parent) && (c->inversep))) &&
|
||||
(c->type == RDF_RESOURCE_TYPE) && (c->tv))
|
||||
{
|
||||
if (startsWith("find:", resourceID(c->u)))
|
||||
{
|
||||
if (c->pdata != NULL)
|
||||
{
|
||||
/* Note: at creation, we had to copy "v",
|
||||
so free it here */
|
||||
if ((value = ((RDF_Cursor)(c->pdata))->value) != NULL)
|
||||
{
|
||||
freeMem(value);
|
||||
((RDF_Cursor)(c->pdata))->value = NULL;
|
||||
}
|
||||
RDF_DisposeCursor((RDF_Cursor)(c->pdata));
|
||||
c->pdata = NULL;
|
||||
}
|
||||
}
|
||||
freeMem(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
err = remoteStoreDisposeCursor (mcf, c);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
findPossiblyAddName(RDFT rdf, RDF_Resource u)
|
||||
{
|
||||
findTokenStruct tokens[5];
|
||||
char *name;
|
||||
|
||||
if ((name = (char *)remoteStoreGetSlotValue(rdf, u, gCoreVocab->RDF_name,
|
||||
RDF_STRING_TYPE, PR_FALSE, PR_TRUE)) == NULL)
|
||||
{
|
||||
/* build up a token list */
|
||||
tokens[0].token = "location"; tokens[0].value = NULL;
|
||||
tokens[1].token = "attribute"; tokens[1].value = NULL;
|
||||
tokens[2].token = "method"; tokens[2].value = NULL;
|
||||
tokens[3].token = "value"; tokens[3].value = NULL;
|
||||
tokens[4].token = NULL; tokens[4].value = NULL;
|
||||
|
||||
parseResourceIntoFindTokens(u, tokens);
|
||||
|
||||
if ((name = PR_smprintf(XP_GetString(RDF_FIND_FULLNAME_STR),
|
||||
((tokens[1].value != NULL) ? tokens[1].value : ""),
|
||||
((tokens[2].value != NULL) ? tokens[2].value : ""),
|
||||
((tokens[3].value != NULL) ? tokens[3].value : ""))) != NULL)
|
||||
{
|
||||
remoteStoreAdd(rdf, u, gCoreVocab->RDF_name, name,
|
||||
RDF_STRING_TYPE, PR_TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
FindAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
/* don't handle the assert, but simply add a name if it doesn't already have one */
|
||||
|
||||
if (startsWith("find:", resourceID(u)))
|
||||
{
|
||||
findPossiblyAddName(rdf, u);
|
||||
}
|
||||
return(PR_FALSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeFindStore (char *url)
|
||||
{
|
||||
RDFT ntr = NULL;
|
||||
|
||||
if (gRDFFindDB != NULL) return(gRDFFindDB);
|
||||
|
||||
if (strstr(url, "rdf:find"))
|
||||
{
|
||||
if ((ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct))) != NULL)
|
||||
{
|
||||
ntr->assert = FindAssert;
|
||||
ntr->unassert = NULL;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->getSlotValue = FindGetSlotValue;
|
||||
ntr->getSlotValues = FindGetSlotValues;
|
||||
ntr->nextValue = FindNextValue;
|
||||
ntr->disposeCursor = FindDisposeCursor;
|
||||
ntr->possiblyAccessFile = FindPossible;
|
||||
ntr->destroy = NULL;
|
||||
ntr->url = copyString(url);
|
||||
gRDFFindDB = ntr;
|
||||
}
|
||||
}
|
||||
return(ntr);
|
||||
}
|
||||
52
mozilla/modules/rdf/src/find2rdf.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_FIND_H_
|
||||
#define _RDF_FIND_H_
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
||||
/* find.c data structures and defines */
|
||||
|
||||
typedef struct _findTokenStruct {
|
||||
char *token;
|
||||
char *value;
|
||||
} findTokenStruct;
|
||||
|
||||
|
||||
/* find.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void parseResourceIntoFindTokens(RDF_Resource u, findTokenStruct *tokens);
|
||||
RDF_Cursor parseFindURL(RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
RDF_Cursor FindGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * findNextURL(RDF_Cursor c);
|
||||
void * FindNextValue(RDFT rdf, RDF_Cursor c);
|
||||
void * FindGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void FindPossible(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Error FindDisposeCursor(RDFT mcf, RDF_Cursor c);
|
||||
void findPossiblyAddName(RDFT rdf, RDF_Resource u);
|
||||
PRBool FindAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
RDFT MakeFindStore (char* url);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
1143
mozilla/modules/rdf/src/fs2rdf.c
Normal file
84
mozilla/modules/rdf/src/fs2rdf.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_FS2RDF_H_
|
||||
#define _RDF_FS2RDF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "xp_mem.h"
|
||||
#include "client.h"
|
||||
#include "prio.h"
|
||||
#include "prlong.h"
|
||||
#include "nlcstore.h"
|
||||
#include "remstore.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include <Appletalk.h>
|
||||
#include <Devices.h>
|
||||
#include <Files.h>
|
||||
#include <FinderRegistry.h>
|
||||
#include <Folders.h>
|
||||
#include <Processes.h>
|
||||
|
||||
#include "FullPath.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* fs2rdf.c data structures and defines */
|
||||
|
||||
extern int RDF_VOLUME_DESC_STR, RDF_DIRECTORY_DESC_STR, RDF_FILE_DESC_STR;
|
||||
|
||||
#define fsUnitp(u) (resourceType(u) == LFS_RT)
|
||||
|
||||
#define XP_DIRECTORY_SEPARATOR '/'
|
||||
|
||||
|
||||
|
||||
|
||||
/* fs2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
#ifdef XP_MAC
|
||||
OSErr nativeMacPathname(char *fileURL, FSSpec *fss);
|
||||
OSErr getPSNbyTypeSig(ProcessSerialNumber *thePSN, OSType pType, OSType pSignature);
|
||||
#endif
|
||||
|
||||
void importForProfile (char *dir, const char *uname);
|
||||
void GuessIEBookmarks(void);
|
||||
char * getVolume(int16 volNum, PRBool afpVols);
|
||||
PRDir * OpenDir(char *name);
|
||||
RDFT MakeLFSStore (char* url);
|
||||
PRBool fsAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
PRBool fsRemoveFile(char *filePathname, PRBool justCheckWriteAccess);
|
||||
PRBool fsRemoveDir(char *filePathname, PRBool justCheckWriteAccess);
|
||||
PRBool fsUnassert (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
PRBool fsHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
void * fsGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
PRBool fileDirectoryp(RDF_Resource u);
|
||||
RDF_Cursor fsGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
void * fsNextValue (RDFT rdf, RDF_Cursor c);
|
||||
PRBool isFileVisible(char *fileURL);
|
||||
RDF_Error fsDisposeCursor (RDFT rdf, RDF_Cursor c);
|
||||
RDF_Resource CreateFSUnit (char* nname, PRBool isDirectoryFlag);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
469
mozilla/modules/rdf/src/glue.c
Normal file
@@ -0,0 +1,469 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the glue code that links the RDF module with
|
||||
* ugly navigator stuff including Netlib for getURL, preferences for
|
||||
* finding out where bookmarks.htm and lclstore.mcf are located. By
|
||||
* changing this glue file, one should be able to use the rest of the
|
||||
* RDF library with something else (like the server).
|
||||
|
||||
* For more information on this file, contact rjc or guha
|
||||
* For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "rdf-int.h"
|
||||
#include "glue.h"
|
||||
#include "remstore.h"
|
||||
#include "rdfparse.h"
|
||||
#include "es2mcf.h"
|
||||
#include "mcff2mcf.h"
|
||||
#include "nlcstore.h"
|
||||
#include "autoupdt.h"
|
||||
#include "ht.h"
|
||||
#ifdef NU_CACHE
|
||||
#include "CacheStubs.h"
|
||||
#endif
|
||||
|
||||
/* external routines */
|
||||
extern MWContext *FE_GetRDFContext(void);
|
||||
extern char *gDefaultNavcntr;
|
||||
extern RDF gNCDB;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
unsigned int
|
||||
rdf_write_ready(NET_StreamClass *stream)
|
||||
{
|
||||
return MAX_WRITE_READY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_complete(NET_StreamClass *stream)
|
||||
{
|
||||
RDFFile f = (RDFFile)stream->data_object;
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0) {
|
||||
if (f->resourceCount == 0) {
|
||||
parseNextRDFXMLBlob(stream, gDefaultNavcntr, RDF_STRLEN(gDefaultNavcntr));
|
||||
} else {
|
||||
RDF_Resource browser = RDF_GetResource(NULL, "netscape:browser", 1);
|
||||
RDF_Resource updateFrom = RDF_GetResource(NULL, "updateURL", 1);
|
||||
char* uf = RDF_GetSlotValue(gNCDB, browser, updateFrom,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
RDF_Resource fileSize = RDF_GetResource(NULL, "fileSize", 1);
|
||||
char* fs = RDF_GetSlotValue(gNCDB, browser, fileSize,
|
||||
RDF_STRING_TYPE, false, true);
|
||||
uint32 fSize;
|
||||
if (fs == NULL) {
|
||||
fSize = 3000;
|
||||
} else {
|
||||
sscanf("%lu", fs, &fSize);
|
||||
freeMem(fs);
|
||||
}
|
||||
if (uf != NULL) {
|
||||
#ifdef MOZ_SMARTUPDATE
|
||||
checkForAutoUpdate((void *)FE_GetRDFContext(), uf, fSize);
|
||||
#endif /* MOZ_SMARTUPDATE */
|
||||
freeMem(uf);
|
||||
}
|
||||
|
||||
/* A temporary hack to demo AutoUpdate on windows */
|
||||
#ifndef MOZ_SMARTUPDATE
|
||||
#ifdef XP_WIN
|
||||
checkForAutoUpdate((void *)FE_GetRDFContext(), "http://warp/u/raman/gromit/softupdt.exe", 45328);
|
||||
#endif /* XP_WIN */
|
||||
#endif /* MOZ_SMARTUPDATE */
|
||||
|
||||
}
|
||||
}
|
||||
if (f) {
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
freeNamespaces(f) ;
|
||||
f->line = NULL;
|
||||
f->currentSlot = NULL;
|
||||
f->holdOver = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_abort(NET_StreamClass *stream, int status)
|
||||
{
|
||||
RDFFile f = (RDFFile)stream->data_object;
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0) {
|
||||
parseNextRDFXMLBlob(stream, gDefaultNavcntr, RDF_STRLEN(gDefaultNavcntr));
|
||||
}
|
||||
|
||||
if (f) {
|
||||
f->locked = false;
|
||||
gcRDFFile (f);
|
||||
freeMem(f->line);
|
||||
freeMem(f->currentSlot);
|
||||
freeMem(f->holdOver);
|
||||
freeNamespaces(f) ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
#ifdef XP_MAC
|
||||
PR_PUBLIC_API(NET_StreamClass *)
|
||||
#else
|
||||
PUBLIC NET_StreamClass *
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
parseNextRDFXMLBlob (NET_StreamClass *stream, char* blob, int32 size)
|
||||
{
|
||||
RDFFile f;
|
||||
|
||||
f = (RDFFile)stream->data_object;
|
||||
if ((f == NULL) || (size < 0)) {
|
||||
return MK_INTERRUPTED;
|
||||
}
|
||||
return parseNextRDFXMLBlobInt(f, blob, size);
|
||||
}
|
||||
|
||||
rdf_Converter(FO_Present_Types format_out, void *client_data,
|
||||
URL_Struct *urls, MWContext *cx)
|
||||
{
|
||||
RDFFile rdfFile;
|
||||
MKStreamWriteFunc writeFunc = NULL;
|
||||
|
||||
if ((urls == NULL) || (urls->fe_data == NULL))
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* determine appropriate write function to use */
|
||||
rdfFile = urls->fe_data;
|
||||
switch(rdfFile->fileType)
|
||||
{
|
||||
/* case ES_RT:
|
||||
case FTP_RT:
|
||||
writeFunc = (MKStreamWriteFunc)parseNextESFTPBlob;
|
||||
break;
|
||||
*/
|
||||
default:
|
||||
writeFunc = (MKStreamWriteFunc)parseNextRDFXMLBlob;
|
||||
break;
|
||||
}
|
||||
|
||||
/* allocate stream data block */
|
||||
return NET_NewStream("RDF", writeFunc,
|
||||
(MKStreamCompleteFunc)rdf_complete,
|
||||
(MKStreamAbortFunc)rdf_abort,
|
||||
(MKStreamWriteReadyFunc)rdf_write_ready,
|
||||
urls->fe_data, cx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx)
|
||||
{
|
||||
RDFFile f;
|
||||
char *navCenterURL = NULL;
|
||||
|
||||
if ((status < 0) && (urls != NULL))
|
||||
{
|
||||
if ((cx != NULL) && (urls->error_msg != NULL))
|
||||
{
|
||||
FE_Alert(cx, urls->error_msg);
|
||||
}
|
||||
|
||||
/* if unable to read in navcntr.rdf file, create some default views */
|
||||
if ((f = (RDFFile) urls->fe_data) != NULL)
|
||||
{
|
||||
if (RDF_STRCMP(f->url, gNavCntrUrl) == 0)
|
||||
{
|
||||
parseNextRDFXMLBlobInt(f, gDefaultNavcntr,
|
||||
RDF_STRLEN(gDefaultNavcntr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (urls != NULL)
|
||||
{
|
||||
if ((f = (RDFFile) urls->fe_data) != NULL)
|
||||
{
|
||||
htLoadComplete(f->url, status);
|
||||
}
|
||||
}
|
||||
|
||||
NET_FreeURLStruct (urls);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
int
|
||||
rdfRetrievalType (RDFFile f)
|
||||
{
|
||||
URL_Struct *urls;
|
||||
char *url;
|
||||
int type;
|
||||
|
||||
url = f->url;
|
||||
if (f->localp)
|
||||
{
|
||||
urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD);
|
||||
if ((urls != NULL) && (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)))
|
||||
{
|
||||
type = NET_DONT_RELOAD;
|
||||
}
|
||||
else
|
||||
{
|
||||
type = NET_NORMAL_RELOAD;
|
||||
}
|
||||
if (urls != NULL) NET_FreeURLStruct(urls);
|
||||
}
|
||||
else
|
||||
{
|
||||
type = NET_NORMAL_RELOAD;
|
||||
}
|
||||
return(type);
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
int
|
||||
rdf_GetURL (MWContext *cx, int method, Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile)
|
||||
{
|
||||
URL_Struct *urls = NULL;
|
||||
char* url ;
|
||||
#ifdef DEBUG_gagan
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
if (cx == NULL) return 0;
|
||||
if (rdfFile->refreshingp && rdfFile->updateURL) {
|
||||
url = rdfFile->updateURL;
|
||||
} else {
|
||||
url = rdfFile->url;
|
||||
}
|
||||
if (RDF_STRCMP(url, gNavCntrUrl) == 0) {
|
||||
urls = NET_CreateURLStruct(url, NET_CACHE_ONLY_RELOAD);
|
||||
#ifdef NU_CACHE
|
||||
if (!CacheManager_Contains(url)) {
|
||||
#else
|
||||
if (NET_IsURLInDiskCache(urls) || NET_IsURLInMemCache(urls)) {
|
||||
} else {
|
||||
#endif
|
||||
NET_FreeURLStruct(urls);
|
||||
urls = NULL;
|
||||
}
|
||||
}
|
||||
if (!urls)
|
||||
urls = NET_CreateURLStruct(url, (rdfFile->refreshingp ?
|
||||
NET_SUPER_RELOAD : NET_NORMAL_RELOAD));
|
||||
if (urls == NULL) return 0;
|
||||
urls->fe_data = rdfFile;
|
||||
if (method) urls->method = method;
|
||||
NET_GetURL(urls, FO_CACHE_AND_RDF, cx, rdf_GetUrlExitFunc);
|
||||
return 1;
|
||||
}
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyRereadRDFFiles (void* data)
|
||||
{
|
||||
possiblyRefreshRDFFiles();
|
||||
/* timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10);
|
||||
once every 10 minutes
|
||||
diabled for legal reasons.*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDFglueInitialize()
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
timerID = FE_SetTimeout(possiblyRereadRDFFiles, NULL, 1000 * 60 * 10); /* once every 10 minutes */
|
||||
if (gRLForbiddenDomains != NULL)
|
||||
{
|
||||
freeMem(gRLForbiddenDomains);
|
||||
gRLForbiddenDomains = NULL;
|
||||
}
|
||||
if (PREF_CopyCharPref("browser.relatedLinksDisabledForDomains", &gRLForbiddenDomains) != PREF_OK)
|
||||
{
|
||||
gRLForbiddenDomains = NULL;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
RDFglueExit (void)
|
||||
{
|
||||
#ifdef MOZILLA_CLIENT
|
||||
|
||||
if (timerID != NULL)
|
||||
{
|
||||
/* commented out as the timer's window has already been destroyed */
|
||||
|
||||
/* FE_ClearTimeout(timerID); */
|
||||
timerID = NULL;
|
||||
}
|
||||
|
||||
#endif /* MOZILLA_CLIENT */
|
||||
}
|
||||
|
||||
|
||||
void *
|
||||
gRDFMWContext(RDFT db)
|
||||
{
|
||||
#ifndef MOZILLA_CLIENT
|
||||
return NULL;
|
||||
#else
|
||||
void *cx;
|
||||
RDFL rdf = NULL;
|
||||
|
||||
if (db) rdf = db->rdf;
|
||||
|
||||
while (rdf) {
|
||||
if (rdf->rdf->context) return (rdf->rdf->context);
|
||||
rdf = rdf->next;
|
||||
}
|
||||
|
||||
cx = (void *)FE_GetRDFContext();
|
||||
return(cx);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* beginReadingRDFFile is called whenever we need to read something of
|
||||
* the net (or local drive). The url of the file to be read is at
|
||||
* file->url. As the bits are read in (and it can take the bits in
|
||||
* any sized chunks) it should call parseNextRDFBlob(file, nextBlock,
|
||||
* blobSize) when its done, it should call void finishRDFParse
|
||||
* (RDFFile f) to abort, it should call void abortRDFParse (RDFFile f)
|
||||
* [which will undo all that has been read from that file]
|
||||
*/
|
||||
|
||||
void
|
||||
beginReadingRDFFile (RDFFile file)
|
||||
{
|
||||
char *url;
|
||||
int method = 0;
|
||||
|
||||
#ifndef MOZILLA_CLIENT
|
||||
|
||||
/* If standalone, we just use to open the file */
|
||||
NET_StreamClass stream;
|
||||
PRFileDesc *fd;
|
||||
PRFileInfo fi;
|
||||
PRBool bSuccess = FALSE;
|
||||
|
||||
url = file->url;
|
||||
fd = CallPROpenUsingFileURL(url, PR_RDONLY, 0);
|
||||
if(fd)
|
||||
{
|
||||
if(PR_GetOpenFileInfo(fd, &fi) == PR_SUCCESS)
|
||||
{
|
||||
char* buf = malloc(fi.size);
|
||||
if(PR_Read(fd, buf, fi.size))
|
||||
{
|
||||
stream.data_object = file;
|
||||
if(parseNextRDFXMLBlob (&stream, buf, fi.size))
|
||||
bSuccess = TRUE;
|
||||
}
|
||||
free(buf);
|
||||
}
|
||||
PR_Close(fd);
|
||||
}
|
||||
if(bSuccess == TRUE)
|
||||
rdf_complete(&stream);
|
||||
#else
|
||||
|
||||
/*
|
||||
XXX this is the pre-raptor world
|
||||
|
||||
url = file->url;
|
||||
if (file->fileType == ES_RT) method = URL_INDEX_METHOD;
|
||||
rdf_GetURL (gRDFMWContext(file->db), method, NULL, file);
|
||||
*/
|
||||
|
||||
rdfStreamListener* pListener = new rdfStreamListener;
|
||||
pListener->AddRef(); // XXX is this evil? Can't see any reason to use factories but...
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
#ifdef MOZILLA_CLIENT
|
||||
DB *
|
||||
CallDBOpenUsingFileURL(char *fileURL, int flags,int mode, DBTYPE type, const void *openinfo)
|
||||
{
|
||||
DB *result;
|
||||
char *path;
|
||||
char *escapedPath;
|
||||
|
||||
if (fileURL == NULL) return NULL;
|
||||
|
||||
escapedPath = unescapeURL(fileURL);
|
||||
|
||||
#ifdef XP_MAC
|
||||
path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(fileURL));
|
||||
PR_ASSERT(path != NULL);
|
||||
#else
|
||||
|
||||
path = convertFileURLToNSPRCopaceticPath(escapedPath);
|
||||
#endif
|
||||
result = dbopen(path, flags, mode, type, openinfo);
|
||||
#ifdef XP_MAC
|
||||
XP_FREE(path);
|
||||
#endif
|
||||
|
||||
if (escapedPath != NULL) freeMem(escapedPath);
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
#if defined(XP_WIN) && defined(DEBUG)
|
||||
/* Some XP functions that are implemented in winfe
|
||||
* in the client.
|
||||
*/
|
||||
void XP_AssertAtLine( char *pFileName, int iLine )
|
||||
{
|
||||
fprintf(stderr, "assert: line %d, file %s%c\n", __LINE__, pFileName, 7);
|
||||
}
|
||||
|
||||
char* NOT_NULL(const char* x)
|
||||
{
|
||||
return (char*)x;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
90
mozilla/modules/rdf/src/glue.h
Normal file
@@ -0,0 +1,90 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_GLUE_H_
|
||||
#define _RDF_GLUE_H_
|
||||
|
||||
|
||||
#include "xp.h"
|
||||
#include "xp_mem.h"
|
||||
#include "net.h"
|
||||
#include "ntypes.h"
|
||||
#include "fe_proto.h"
|
||||
|
||||
#include "prinit.h"
|
||||
|
||||
#ifdef XP_UNIX
|
||||
#include <sys/fcntl.h>
|
||||
#elif defined(XP_MAC)
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "ht.h"
|
||||
|
||||
|
||||
|
||||
#define APPLICATION_RDF "application/x-rdf" /* XXX what should these be? */
|
||||
#define EXTENSION_RDF ".rdf"
|
||||
#define EXTENSION_MCF ".mcf"
|
||||
|
||||
|
||||
|
||||
/* external globals */
|
||||
extern char* gLocalStoreURL;
|
||||
extern char* gBookmarkURL;
|
||||
|
||||
|
||||
|
||||
/* glue.c prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void ht_fprintf(PRFileDesc *file, const char *fmt, ...);
|
||||
|
||||
unsigned int rdf_write_ready(NET_StreamClass *stream);
|
||||
void rdf_complete(NET_StreamClass *stream);
|
||||
void rdf_abort(NET_StreamClass *stream, int status);
|
||||
NET_StreamClass * rdf_Converter(FO_Present_Types format_out,
|
||||
void *client_data, URL_Struct *urls, MWContext *cx);
|
||||
void rdf_GetUrlExitFunc (URL_Struct *urls, int status, MWContext *cx);
|
||||
int rdfRetrievalType (RDFFile f);
|
||||
int rdf_GetURL (MWContext *cx, int method,
|
||||
Net_GetUrlExitFunc *exit_routine, RDFFile rdfFile);
|
||||
void possiblyRereadRDFFiles (void* data);
|
||||
void RDFglueInitialize (void);
|
||||
void RDFglueExit (void);
|
||||
void *gRDFMWContext(RDFT db);
|
||||
void beginReadingRDFFile (RDFFile file);
|
||||
void readLocalFile (RDFFile file);
|
||||
|
||||
char *unescapeURL(char *inURL);
|
||||
char *convertFileURLToNSPRCopaceticPath(char* inURL);
|
||||
PRFileDesc *CallPROpenUsingFileURL(char *fileURL, PRIntn flags, PRIntn mode);
|
||||
PRDir *CallPROpenDirUsingFileURL(char *fileURL);
|
||||
int32 CallPRWriteAccessFileUsingFileURL(char *fileURL);
|
||||
int32 CallPRDeleteFileUsingFileURL(char *fileURL);
|
||||
int CallPR_RmDirUsingFileURL(char *dirURL);
|
||||
int32 CallPRMkDirUsingFileURL(char *dirURL, int mode);
|
||||
DB *CallDBOpenUsingFileURL(char *fileURL, int flags,int mode,
|
||||
DBTYPE type, const void *openinfo);
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
675
mozilla/modules/rdf/src/hist2rdf.c
Normal file
@@ -0,0 +1,675 @@
|
||||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements History support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
#include "hist2rdf.h"
|
||||
#include "remstore.h"
|
||||
#include "utils.h"
|
||||
|
||||
static PRBool histInFlatFilep = 0;
|
||||
|
||||
/* extern declarations */
|
||||
void GH_DeleteHistoryItem (char * url);
|
||||
PR_PUBLIC_API(void) updateNewHistItem (DBT *key, DBT *data); /* XXX this should be elsewhere */
|
||||
|
||||
|
||||
/* externs */
|
||||
extern char *profileDirURL;
|
||||
extern char *gGlobalHistoryURL;
|
||||
|
||||
|
||||
/* external string references in allxpstr */
|
||||
extern int RDF_WEEKOF, RDF_WITHINLASTHOUR, RDF_TODAY, RDF_DAY_0;
|
||||
extern int RDF_RELATEDLINKSNAME;
|
||||
|
||||
|
||||
/* globals */
|
||||
PLHashTable *hostHash = 0;
|
||||
RDFT grdf = NULL;
|
||||
RDFT gHistoryStore = 0;
|
||||
PRBool ByDateOpened = 0;
|
||||
PRBool historyInitialized = 0;
|
||||
static int saveCount = 0;
|
||||
|
||||
|
||||
char *prefixList[] = {
|
||||
"about:", "javascript:", "livescript:", "mailbox:", "mailto:",
|
||||
"mocha:", "news:", "pop3", "snews:", "view-source", "wysiwyg:", NULL
|
||||
};
|
||||
|
||||
char *suffixList[] = {
|
||||
".gif", ".jpg", ".jpeg", ".xbm", ".pfr", ".class", ".tmp", ".js", ".rdf",
|
||||
".mcf", ".mco", NULL
|
||||
};
|
||||
|
||||
char *intermediateList[] = {
|
||||
".gif", ".GIF", NULL
|
||||
};
|
||||
|
||||
|
||||
|
||||
void
|
||||
collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag)
|
||||
{
|
||||
HASHINFO hash = { 4*1024, 0, 0, 0, 0, 0};
|
||||
DBT key, data;
|
||||
time_t last,first;
|
||||
uint32 numaccess;
|
||||
PRBool firstOne = 0;
|
||||
DB* db = CallDBOpenUsingFileURL(gGlobalHistoryURL, O_RDONLY ,0600,
|
||||
DB_HASH, &hash);
|
||||
grdf = r;
|
||||
if (db != NULL) {
|
||||
while (0 == (*db->seq)(db, &key, &data, (firstOne ? R_NEXT : R_FIRST))) {
|
||||
char* title = ((char*)data.data + 16); /* title */
|
||||
char* url = (char*)key.data; /* url */
|
||||
/* int32 flag = (int32)*((char*)data.data + 3*sizeof(int32)); */
|
||||
int32 flag;
|
||||
HIST_COPY_INT32(&flag, (int8 *)data.data + 3 * sizeof(int32));
|
||||
firstOne = 1;
|
||||
#ifdef XP_UNIX
|
||||
if ((/*1 == flag &&*/ displayHistoryItem((char*)key.data))) {
|
||||
#else
|
||||
if (1 == flag && displayHistoryItem((char*)key.data)) {
|
||||
#endif
|
||||
HIST_COPY_INT32(&last, (time_t *)((int8 *)data.data));
|
||||
HIST_COPY_INT32(&first, (time_t *)((int8 *)data.data + sizeof(int32)));
|
||||
HIST_COPY_INT32(&numaccess, (time_t *)((int8 *)data.data + 2*sizeof(int32)));
|
||||
|
||||
collateOneHist(r, u,url,title, last, first, numaccess, byDateFlag);
|
||||
}
|
||||
}
|
||||
(*db->close)(db);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate,
|
||||
time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag)
|
||||
{
|
||||
char buffer[128];
|
||||
struct tm *time;
|
||||
RDF_Resource hostUnit, urlUnit;
|
||||
char* existingName = NULL;
|
||||
uint32 oldNumAccess = 0;
|
||||
if (startsWith("404", title)) return;
|
||||
urlUnit = HistCreate(url, 1);
|
||||
existingName = remoteStoreGetSlotValue(gLocalStore, urlUnit, gCoreVocab->RDF_name, RDF_STRING_TYPE, 0, 1);
|
||||
|
||||
PR_ASSERT( IsUTF8String((const char* )existingName));
|
||||
|
||||
if (existingName == NULL) {
|
||||
if (title[0] != '\0') remoteAddName(urlUnit, title);
|
||||
} else freeMem(existingName);
|
||||
if (byDateFlag) {
|
||||
hostUnit = hostUnitOfDate(r, u, lastAccessDate);
|
||||
} else {
|
||||
hostUnit = hostUnitOfURL(r, u, urlUnit, title);
|
||||
}
|
||||
|
||||
if (hostUnit == NULL) return;
|
||||
|
||||
|
||||
if (hostUnit != urlUnit) remoteAddParent(urlUnit, hostUnit);
|
||||
|
||||
if ((time = localtime((time_t *) &lastAccessDate)) != NULL)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
PR_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_lastVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
if ((time = localtime((time_t *) &firstAccessDate)) != NULL)
|
||||
{
|
||||
#ifdef XP_MAC
|
||||
time->tm_year += 4;
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#elif XP_UNIX
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_MACDATE),time);
|
||||
#else
|
||||
strftime(buffer,sizeof(buffer),XP_GetString(RDF_HTML_WINDATE),time);
|
||||
#endif
|
||||
PR_ASSERT( IsUTF8String((const char* )buffer));
|
||||
remoteStoreAdd(gRemoteStore, urlUnit, gWebData->RDF_firstVisitDate,
|
||||
(void *)copyString(buffer), RDF_STRING_TYPE, 1);
|
||||
}
|
||||
/* oldNumAccess = remoteStoreGetSlotValue(gHistoryStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
RDF_INT_TYPE, 0, 1);
|
||||
if (oldNumAccess) remoteStoreRemove(gHistoryStore, urlUnit, gWebData->RDF_numAccesses, oldNumAccess,
|
||||
RDF_INT_TYPE);
|
||||
if (numAccesses==0) ++numAccesses;
|
||||
remoteStoreAdd(gHistoryStore, urlUnit, gWebData->RDF_numAccesses,
|
||||
(void *)numAccesses, RDF_INT_TYPE, 1); */
|
||||
if (numAccesses > 5) histAddParent(urlUnit, gNavCenter->RDF_HistoryMostVisited);
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title)
|
||||
{
|
||||
char host[100];
|
||||
char* url = resourceID(nu);
|
||||
int16 s1, s2, s3;
|
||||
RDF_Resource hostResource, existing;
|
||||
if (RDF_STRLEN(url) > 100) return NULL;
|
||||
if (startsWith("file", url)) {
|
||||
return RDF_GetResource(NULL, "Local Files", 1);
|
||||
} else {
|
||||
memset(host, '\0', 100);
|
||||
s1 = charSearch(':', url)+3;
|
||||
s2 = charSearch('/', &url[s1]);
|
||||
s3 = charSearch(':', &url[s1]);
|
||||
if (s2 == -1) s2 = RDF_STRLEN(url)-s1;
|
||||
if ((s3 != -1) && (s2 > s3)) s2 = s3;
|
||||
if (startsWith("www", &url[s1])) {s1 = s1+4; s2 = s2-4;}
|
||||
if (s2<1) return(NULL);
|
||||
memcpy((char*)host, &url[s1], s2);
|
||||
host[0] = toupper(host[0]);
|
||||
hostResource = RDF_GetResource(NULL, host, 1);
|
||||
setContainerp(hostResource, 1);
|
||||
setResourceType(hostResource, HISTORY_RT);
|
||||
existing = PL_HashTableLookup(hostHash, hostResource);
|
||||
if (existing != NULL) {
|
||||
if (existing == nu) {
|
||||
return existing;
|
||||
} else if (existing == top) {
|
||||
return hostResource;
|
||||
} else {
|
||||
remoteStoreRemove(gHistoryStore, existing, gCoreVocab->RDF_parent, top, RDF_RESOURCE_TYPE);
|
||||
histAddParent(existing, hostResource);
|
||||
histAddParent(hostResource, top);
|
||||
PL_HashTableAdd(hostHash, hostResource, top);
|
||||
return hostResource;
|
||||
}
|
||||
} else {
|
||||
PL_HashTableAdd(hostHash, hostResource, nu);
|
||||
histAddParent(nu, top);
|
||||
return nu;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
hourRange(char *buffer, struct tm *theTm)
|
||||
{
|
||||
char *startHourStr="AM",*endHourStr="AM";
|
||||
|
||||
if (theTm->tm_hour > 0 && theTm->tm_hour < 12) {
|
||||
sprintf(buffer, "AM");
|
||||
} else {
|
||||
sprintf(buffer, "PM");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate)
|
||||
{
|
||||
RDF_Resource node = NULL, parentNode;
|
||||
/*
|
||||
RDF_Resources std;
|
||||
*/
|
||||
time_t now, tempTime;
|
||||
struct tm *T,nowStruct, dateStruct;
|
||||
char hourBuffer[128], dayBuffer[128], weekBuffer[128];
|
||||
char bigBuffer[1024];
|
||||
int numDays;
|
||||
|
||||
/* NOTE: localtime uses a single static buffer, so MUST copy contents out */
|
||||
|
||||
time((time_t *)&now);
|
||||
if ((T = localtime(&now)) == NULL) return(NULL);
|
||||
nowStruct = *T;
|
||||
|
||||
if ((T = localtime(&lastAccessDate)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
|
||||
bigBuffer[0] = hourBuffer[0] = dayBuffer[0] = weekBuffer[0] = 0;
|
||||
|
||||
if (now < (lastAccessDate + SECS_IN_HOUR)) /* within the last hour */
|
||||
{
|
||||
strcpy(hourBuffer, XP_GetString(RDF_WITHINLASTHOUR));
|
||||
}
|
||||
else if ((nowStruct.tm_year == dateStruct.tm_year) && /* some time today */
|
||||
(nowStruct.tm_yday == dateStruct.tm_yday))
|
||||
{
|
||||
strcpy(dayBuffer, XP_GetString(RDF_TODAY));
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
}
|
||||
else /* check if within last week */
|
||||
{
|
||||
numDays = 7;
|
||||
do
|
||||
{
|
||||
now -= SECS_IN_DAY;
|
||||
if ((T = localtime(&now)) == NULL) return(NULL);
|
||||
nowStruct = *T;
|
||||
if ((nowStruct.tm_year == dateStruct.tm_year) &&
|
||||
(nowStruct.tm_yday == dateStruct.tm_yday))
|
||||
{
|
||||
sprintf(dayBuffer, "%d/%d - %s",
|
||||
(uint) dateStruct.tm_mon + 1, (uint)dateStruct.tm_mday,
|
||||
XP_GetString(RDF_DAY_0 + nowStruct.tm_wday));
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
break;
|
||||
}
|
||||
} while (numDays-- > 0);
|
||||
|
||||
if (dayBuffer[0] == '\0') /* older than a week */
|
||||
{
|
||||
tempTime = lastAccessDate;
|
||||
numDays = dateStruct.tm_wday;
|
||||
while (numDays-- > 0)
|
||||
{
|
||||
tempTime -= SECS_IN_DAY;
|
||||
}
|
||||
if ((T = localtime(&tempTime)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
#ifdef XP_MAC
|
||||
/* Mac epoch according to localtime is 1904 */
|
||||
PR_snprintf(weekBuffer, sizeof(weekBuffer)-1, XP_GetString(RDF_WEEKOF), (uint)dateStruct.tm_mon + 1,
|
||||
(int)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1904);
|
||||
#else
|
||||
PR_snprintf(weekBuffer, sizeof(weekBuffer)-1, XP_GetString(RDF_WEEKOF), (uint)dateStruct.tm_mon + 1,
|
||||
(int)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1900);
|
||||
#endif
|
||||
|
||||
if ((T = localtime(&lastAccessDate)) == NULL) return(NULL);
|
||||
dateStruct = *T;
|
||||
|
||||
#ifdef XP_MAC
|
||||
/* Mac epoch according to localtime is 1904 */
|
||||
sprintf(dayBuffer, "%s - %d/%d/%d",
|
||||
XP_GetString(RDF_DAY_0 + dateStruct.tm_wday), (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1904);
|
||||
#else
|
||||
sprintf(dayBuffer, "%s - %d/%d/%d",
|
||||
XP_GetString(RDF_DAY_0 + dateStruct.tm_wday), (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday, (uint)dateStruct.tm_year + 1900);
|
||||
#endif
|
||||
hourRange(hourBuffer, &dateStruct);
|
||||
}
|
||||
}
|
||||
parentNode = u;
|
||||
|
||||
if (weekBuffer[0] != '\0')
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, weekBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, weekBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
PR_ASSERT( IsUTF8String((const char* )weekBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(weekBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
if (dayBuffer[0] != '\0')
|
||||
{
|
||||
sprintf(bigBuffer, "%d/%d", (uint) dateStruct.tm_mon + 1,
|
||||
(uint)dateStruct.tm_mday);
|
||||
|
||||
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
histAddParent(node, parentNode);
|
||||
sprintf(bigBuffer,"%s - %s",weekBuffer,dayBuffer);
|
||||
PR_ASSERT( IsUTF8String((const char* )dayBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(dayBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
if (hourBuffer[0] == 'W')
|
||||
{
|
||||
sprintf(bigBuffer, "%s", hourBuffer);
|
||||
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, false)) == NULL)
|
||||
{
|
||||
if ((node = RDF_GetResource(NULL, bigBuffer, true)) == NULL) return(NULL);
|
||||
}
|
||||
setContainerp(node, 1);
|
||||
setResourceType(node, HISTORY_RT);
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_parent,
|
||||
parentNode, RDF_RESOURCE_TYPE, 1);
|
||||
PR_ASSERT( IsUTF8String((const char* )hourBuffer));
|
||||
remoteStoreAdd(gHistoryStore, node, gCoreVocab->RDF_name,
|
||||
copyString(hourBuffer), RDF_STRING_TYPE, 1);
|
||||
parentNode = node;
|
||||
}
|
||||
return (node);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
saveHistory ()
|
||||
{
|
||||
char* escapedPath = unescapeURL(gGlobalHistoryURL);
|
||||
char* path = WH_FilePlatformName(convertFileURLToNSPRCopaceticPath(escapedPath));
|
||||
PRFileDesc* file = PR_Open(path, PR_WRONLY | PR_CREATE_FILE, 00200);
|
||||
char* hist;
|
||||
if (file != NULL) {
|
||||
hist = RDF_SerializeRDFStore(gHistoryStore) ;
|
||||
if (hist != NULL) {
|
||||
PR_Write(file, hist, RDF_STRLEN(hist));
|
||||
}
|
||||
}
|
||||
freeMem(path);
|
||||
freeMem(escapedPath);
|
||||
PR_Close(file);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PR_PUBLIC_API(void)
|
||||
updateNewHistItem (DBT *key, DBT *data)
|
||||
{
|
||||
time_t last,first,numaccess;
|
||||
int32 flg = (int32)*((char*)data->data + 3*sizeof(int32));
|
||||
if (!displayHistoryItem((char*)key->data)) return;
|
||||
if (historyInitialized && (gHistoryStore != NULL)) {
|
||||
HIST_COPY_INT32(&last, (time_t *)((char *)data->data));
|
||||
HIST_COPY_INT32(&first, (time_t *)((char *)data->data + sizeof(int32)));
|
||||
HIST_COPY_INT32(&numaccess, (time_t *)((char *)data->data + 2*sizeof(int32)));
|
||||
|
||||
if (hostHash) collateOneHist(grdf, gNavCenter->RDF_HistoryBySite,
|
||||
(char*)key->data, /* url */
|
||||
((char*)data->data + 4*sizeof(int32)), /* title */
|
||||
last, first, numaccess, 0);
|
||||
if (ByDateOpened) collateOneHist(grdf, gNavCenter->RDF_HistoryByDate,
|
||||
(char*)key->data, /* url */
|
||||
((char*)data->data + 4*sizeof(int32)), /* title */
|
||||
last, first, numaccess, 1);
|
||||
saveCount++;
|
||||
if (saveCount > 5) {
|
||||
if (histInFlatFilep) saveHistory();
|
||||
saveCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** History clustering utils **/
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
displayHistoryItem (char* url)
|
||||
{
|
||||
int x;
|
||||
x=0;
|
||||
while (prefixList[x]) {
|
||||
if (startsWith(prefixList[x++], url)) return 0;
|
||||
}
|
||||
x=0;
|
||||
while (suffixList[x]) {
|
||||
if (endsWith(suffixList[x++], url)) return 0;
|
||||
}
|
||||
x=0;
|
||||
while (intermediateList[x]) {
|
||||
if (strstr(url, intermediateList[x++])) return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
HistCreate (char* url, PRBool createp)
|
||||
{
|
||||
size_t size = RDF_STRLEN(url);
|
||||
char* nurl = getMem(size+8);
|
||||
RDF_Resource ans;
|
||||
if (charSearch(':', url) == -1) {
|
||||
if (url[size-1] == '/') {
|
||||
sprintf(nurl, "http://%s", url);
|
||||
nurl[RDF_STRLEN(nurl)-1] = '\0';
|
||||
} else {
|
||||
sprintf(nurl, "http://%s/", url);
|
||||
}
|
||||
} else {
|
||||
if (url[size-1] == '/') {
|
||||
memcpy(nurl, url, size-1);
|
||||
} else {
|
||||
sprintf(nurl, "%s/", url);
|
||||
}
|
||||
}
|
||||
ans = RDF_GetResource(NULL, nurl, 0);
|
||||
if (ans != NULL) {
|
||||
freeMem(nurl);
|
||||
return ans;
|
||||
}
|
||||
freeMem(nurl);
|
||||
ans = RDF_GetResource(NULL, url, createp);
|
||||
|
||||
if (ans != NULL) {
|
||||
return ans;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
PRBool bySite = 0;
|
||||
|
||||
Assertion
|
||||
histAddParent (RDF_Resource child, RDF_Resource parent)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
RDF_Resource s = gCoreVocab->RDF_parent;
|
||||
RDF_ValueType type = RDF_RESOURCE_TYPE;
|
||||
nextAs = prevAs = child->rarg1;
|
||||
while (nextAs != null) {
|
||||
if (asEqual(gHistoryStore, nextAs, child, s, parent, type)) return null;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(gHistoryStore, child, s, parent, type, 1);
|
||||
if (prevAs == null) {
|
||||
child->rarg1 = newAs;
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
nextAs = prevAs = parent->rarg2;
|
||||
if (nextAs == NULL) {
|
||||
parent->rarg2 = newAs;
|
||||
} else {
|
||||
PRBool added = 0;
|
||||
if (bySite) {
|
||||
while (nextAs && !isSeparator(nextAs->u)) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (nextAs) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
while (nextAs != null) {
|
||||
char* nid = resourceID(nextAs->u);
|
||||
if (RDF_STRCMP(resourceID(child), resourceID(nextAs->u)) > 0) {
|
||||
if (prevAs == nextAs) {
|
||||
newAs->invNext = prevAs;
|
||||
parent->rarg2 = newAs;
|
||||
added = 1;
|
||||
break;
|
||||
} else {
|
||||
newAs->invNext = nextAs;
|
||||
prevAs->invNext = newAs;
|
||||
added = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (!added) prevAs->invNext = newAs;
|
||||
}
|
||||
sendNotifications2(gHistoryStore, RDF_ASSERT_NOTIFY, child, s, parent, type, 1);
|
||||
/* XXX have to mark the entire subtree XXX */
|
||||
/* sendNotifications(gHistoryStore->rdf, RDF_ASSERT_NOTIFY, child, s, parent, type, 1); */
|
||||
return(newAs);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((type == RDF_RESOURCE_TYPE) && (resourceType((RDF_Resource)v) == HISTORY_RT) &&
|
||||
(s == gCoreVocab->RDF_parent)) {
|
||||
RDF_Resource parents[5];
|
||||
int8 n = 0;
|
||||
Assertion as = u->rarg1;
|
||||
memset(parents, '\0', 5 * sizeof(RDF_Resource));
|
||||
while (as) {
|
||||
if ((as->type == RDF_RESOURCE_TYPE) && (as->s == gCoreVocab->RDF_parent) &&
|
||||
(resourceType((RDF_Resource)as->value) == HISTORY_RT) && (n < 5)) {
|
||||
parents[n++] = (RDF_Resource)as->value;
|
||||
}
|
||||
as = as->next;
|
||||
}
|
||||
if (containerp(u)) {
|
||||
Assertion as = u->rarg2;
|
||||
while (as) {
|
||||
if ((as->db == gHistoryStore) && (as->s == gCoreVocab->RDF_parent)) {
|
||||
GH_DeleteHistoryItem (resourceID(as->u));
|
||||
}
|
||||
as = as->invNext;
|
||||
}
|
||||
} else {
|
||||
GH_DeleteHistoryItem (resourceID(u));
|
||||
}
|
||||
|
||||
while (n > 0) {
|
||||
n = n - 1;
|
||||
if (parents[n]) {
|
||||
Assertion nas = remoteStoreRemove (gHistoryStore, u, gCoreVocab->RDF_parent,
|
||||
parents[n], RDF_RESOURCE_TYPE);
|
||||
freeMem(nas);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void
|
||||
HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
|
||||
((u == gNavCenter->RDF_HistoryByDate) || (u == gNavCenter->RDF_HistoryBySite))) {
|
||||
if (histInFlatFilep) {
|
||||
readRDFFile(gGlobalHistoryURL, NULL, 0, gHistoryStore);
|
||||
historyInitialized = 1;
|
||||
} else {
|
||||
collateHistory(rdf, u, (u == gNavCenter->RDF_HistoryByDate));
|
||||
historyInitialized = 1;
|
||||
}
|
||||
} else if ((s == gCoreVocab->RDF_parent) && inversep && (rdf == gHistoryStore) &&
|
||||
(u == gNavCenter->RDF_HistoryMostVisited)) {
|
||||
collateHistory(rdf, gNavCenter->RDF_HistoryBySite, 0);
|
||||
historyInitialized = 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
RDFT
|
||||
MakeHistoryStore (char* url)
|
||||
{
|
||||
if (startsWith("rdf:history", url)) {
|
||||
if (gHistoryStore == 0) {
|
||||
RDFT ntr = (RDFT)getMem(sizeof(struct RDF_TranslatorStruct));
|
||||
RDF_Resource sep = createSeparator();
|
||||
ntr->assert = NULL;
|
||||
ntr->unassert = historyUnassert;
|
||||
ntr->getSlotValue = remoteStoreGetSlotValue;
|
||||
ntr->getSlotValues = remoteStoreGetSlotValues;
|
||||
ntr->hasAssertion = remoteStoreHasAssertion;
|
||||
ntr->nextValue = remoteStoreNextValue;
|
||||
ntr->disposeCursor = remoteStoreDisposeCursor;
|
||||
ntr->possiblyAccessFile = HistPossiblyAccessFile;
|
||||
gHistoryStore = ntr;
|
||||
histInFlatFilep = endsWith(".rdf", gGlobalHistoryURL);
|
||||
ntr->url = copyString(url);
|
||||
hostHash = PL_NewHashTable(500, idenHash, PL_CompareValues, PL_CompareValues, null, null);
|
||||
ByDateOpened = 1;
|
||||
return ntr;
|
||||
} else return gHistoryStore;
|
||||
} else return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
void
|
||||
dumpHist ()
|
||||
{
|
||||
FILE *fp = fopen("history.txt", "w");
|
||||
HASHINFO hash = { 4*1024, 0, 0, 0, 0, 0};
|
||||
DBT key, data;
|
||||
PRBool firstOne = 0;
|
||||
DB* db = CallDBOpenUsingFileURL(gGlobalHistoryURL, O_RDONLY ,0600,
|
||||
DB_HASH, &hash);
|
||||
|
||||
if (db != NULL) {
|
||||
while (0 == (*db->seq)(db, &key, &data, (firstOne ? R_NEXT : R_FIRST))) {
|
||||
firstOne = 1;
|
||||
if ((1 == (int32)*((char*)data.data + 3*sizeof(uint32)) &&
|
||||
displayHistoryItem((char*)key.data))) {
|
||||
fprintf(fp, "%s\n", (char*)key.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
(*db->close)(db);
|
||||
}
|
||||
|
||||
*/
|
||||
84
mozilla/modules/rdf/src/hist2rdf.h
Normal file
@@ -0,0 +1,84 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_HIST2RDF_H_
|
||||
#define _RDF_HIST2RDF_H_
|
||||
|
||||
|
||||
#include "rdf-int.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prtypes.h" /* for IS_LITTLE_ENDIAN / IS_BIG_ENDIAN */
|
||||
|
||||
|
||||
|
||||
#if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
|
||||
#error Must have a byte order
|
||||
#endif
|
||||
|
||||
#ifdef IS_LITTLE_ENDIAN
|
||||
#define HIST_COPY_INT32(_a,_b) XP_MEMCPY(_a, _b, sizeof(int32));
|
||||
#else
|
||||
#define HIST_COPY_INT32(_a,_b) \
|
||||
do { \
|
||||
((char *)(_a))[0] = ((char *)(_b))[3]; \
|
||||
((char *)(_a))[1] = ((char *)(_b))[2]; \
|
||||
((char *)(_a))[2] = ((char *)(_b))[1]; \
|
||||
((char *)(_a))[3] = ((char *)(_b))[0]; \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
/* hist2rdf.c data structures and defines */
|
||||
|
||||
#define remoteAddParent(child, parent) histAddParent(child, parent);
|
||||
#define remoteAddName(u, name) remoteStoreAdd(gRemoteStore, u, gCoreVocab->RDF_name, copyString(name), RDF_STRING_TYPE, 1);
|
||||
|
||||
#define SECS_IN_HOUR (60L * 60L)
|
||||
#define SECS_IN_DAY (SECS_IN_HOUR * 24L)
|
||||
|
||||
extern int RDF_HTML_WINDATE, RDF_HTML_MACDATE;
|
||||
|
||||
|
||||
/* hist2rdf.c function prototypes */
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
void collateHistory (RDFT r, RDF_Resource u, PRBool byDateFlag);
|
||||
void collateOneHist (RDFT r, RDF_Resource u, char* url, char* title, time_t lastAccessDate, time_t firstAccessDate, uint32 numAccesses, PRBool byDateFlag);
|
||||
RDF_Resource hostUnitOfURL (RDFT r, RDF_Resource top, RDF_Resource nu, char* title);
|
||||
void hourRange(char *buffer, struct tm *theTm);
|
||||
RDF_Resource hostUnitOfDate (RDFT r, RDF_Resource u, time_t lastAccessDate);
|
||||
void saveHistory();
|
||||
void deleteCurrentSitemaps (char *address);
|
||||
void addRelatedLinks (char* address);
|
||||
PRBool displayHistoryItem (char* url);
|
||||
RDF_Resource HistCreate (char* url, PRBool createp);
|
||||
Assertion histAddParent (RDF_Resource child, RDF_Resource parent);
|
||||
PRBool historyUnassert (RDFT hst, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type);
|
||||
void HistPossiblyAccessFile (RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep);
|
||||
RDF_Cursor historyStoreGetSlotValuesInt (RDFT mcf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv);
|
||||
PRBool historyStoreHasAssertion (RDFT mcf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv);
|
||||
RDFT MakeHistoryStore (char* url);
|
||||
void dumpHist ();
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
10391
mozilla/modules/rdf/src/ht.c
Normal file
398
mozilla/modules/rdf/src/ht.h
Normal file
@@ -0,0 +1,398 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#ifndef _RDF_HT_H_
|
||||
#define _RDF_HT_H_
|
||||
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
#include "xpassert.h"
|
||||
#include "xp_qsort.h"
|
||||
#include "xp_time.h"
|
||||
#include "client.h"
|
||||
#include "net.h"
|
||||
#include "xpgetstr.h"
|
||||
#include "xp_str.h"
|
||||
#include "htmldlgs.h"
|
||||
#include "xp_ncent.h"
|
||||
#include "xpassert.h"
|
||||
#include "nspr.h"
|
||||
#include "prefapi.h"
|
||||
#include "fe_proto.h"
|
||||
#include "intl_csi.h"
|
||||
|
||||
#ifdef XP_MAC
|
||||
#include "stdlib.h"
|
||||
#include <Aliases.h>
|
||||
#endif
|
||||
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "math.h"
|
||||
#include "htrdf.h"
|
||||
|
||||
#ifdef SMART_MAIL
|
||||
#include "pm2rdf.h"
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include "prprf.h"
|
||||
#include "plhash.h"
|
||||
#include "xp_core.h"
|
||||
#include "rdf.h"
|
||||
#include "rdf-int.h"
|
||||
#include "mcf.h"
|
||||
#include "htrdf.h"
|
||||
#include "vocab.h"
|
||||
|
||||
#ifndef XP_ASSERT
|
||||
#define XP_ASSERT(x)
|
||||
#endif
|
||||
|
||||
#ifndef XP_FREE
|
||||
#define XP_FREE(x) PR_Free((x))
|
||||
#endif
|
||||
|
||||
#ifndef XP_STRCASECMP
|
||||
#define XP_STRCASECMP(x,y) strcmp((x),(y))
|
||||
#endif
|
||||
|
||||
#define MWContext void
|
||||
#endif
|
||||
|
||||
|
||||
/* HT data structures and defines */
|
||||
|
||||
#define ITEM_LIST_SIZE 500 /* XXX ITEM_LIST_SIZE should be dynamic */
|
||||
#define ITEM_LIST_ELEMENT_SIZE 20
|
||||
|
||||
#define NUM_MENU_CMDS 40
|
||||
|
||||
#define RDF_SITEMAP 1
|
||||
#define RDF_RELATED_LINKS 2
|
||||
#define FROM_PAGE 1
|
||||
#define GUESS_FROM_PREVIOUS_PAGE 2
|
||||
|
||||
#define HTDEL remoteStoreRemove
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
/* external string references in allxpstr */
|
||||
extern int RDF_HTML_STR, RDF_HTML_STR_1, RDF_HTML_STR_2, RDF_HTML_STR_3;
|
||||
extern int RDF_HTML_STR_4, RDF_HTML_STR_5, RDF_HTML_STR_NUMBER;
|
||||
extern int RDF_HTML_WINDATE, RDF_HTML_MACDATE, RDF_CMD_0, RDF_DATA_1, RDF_DATA_2;
|
||||
extern int RDF_DELETEFILE, RDF_UNABLETODELETEFILE, RDF_DELETEFOLDER;
|
||||
extern int RDF_UNABLETODELETEFOLDER, RDF_SITEMAPNAME;
|
||||
extern int RDF_RELATEDLINKSNAME, RDF_DEFAULTCOLUMNNAME;
|
||||
extern int RDF_NEWWORKSPACEPROMPT, RDF_DELETEWORKSPACE;
|
||||
extern int RDF_ADDITIONS_ALLOWED, RDF_DELETION_ALLOWED;
|
||||
extern int RDF_ICON_URL_LOCKED, RDF_NAME_LOCKED, RDF_COPY_ALLOWED;
|
||||
extern int RDF_MOVE_ALLOWED, RDF_WORKSPACE_POS_LOCKED;
|
||||
extern int RDF_MAIN_TITLE, RDF_COLOR_TITLE, RDF_HTML_INFOHEADER_STR;
|
||||
extern int RDF_MISSION_CONTROL_TITLE, RDF_TREE_COLORS_TITLE, RDF_SELECTION_COLORS_TITLE;
|
||||
extern int RDF_COLUMN_COLORS_TITLE, RDF_TITLEBAR_COLORS_TITLE, RDF_HTML_MAININFOHEADER_STR;
|
||||
extern int RDF_HTML_EMPTYHEADER_STR, RDF_HTML_COLOR_STR, RDF_SETCOLOR_JS, RDF_DEFAULTCOLOR_JS;
|
||||
extern int RDF_COLOR_LAYER, RDF_HTMLCOLOR_STR;
|
||||
extern int RDF_SELECT_START, RDF_SELECT_END, RDF_SELECT_OPTION;
|
||||
extern int RDF_FIND_STR1, RDF_FIND_STR2, RDF_FIND_INPUT_STR;
|
||||
extern int RDF_LOCAL_LOCATION_STR, RDF_REMOTE_LOCATION_STR, RDF_ALL_LOCATION_STR;
|
||||
extern int RDF_CONTAINS_STR, RDF_IS_STR, RDF_IS_NOT_STR, RDF_STARTS_WITH_STR, RDF_ENDS_WITH_STR;
|
||||
extern int RDF_FIND_TITLE, RDF_FIND_FULLNAME_STR, RDF_SHORTCUT_CONFLICT_STR, RDF_FTP_NAME_STR;
|
||||
|
||||
#ifdef HT_PASSWORD_RTNS
|
||||
extern int RDF_NEWPASSWORD, RDF_CONFIRMPASSWORD;
|
||||
extern int RDF_MISMATCHPASSWORD, RDF_ENTERPASSWORD;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#define MISSION_CONTROL_RDF_PREF "browser.navcenter.admin"
|
||||
#define NETSCAPE_RDF_FILENAME "netscape.rdf"
|
||||
|
||||
typedef struct _SBProviderStruct {
|
||||
struct _SBProviderStruct *next;
|
||||
char *url;
|
||||
char *name;
|
||||
PRBool containerp;
|
||||
PRBool openp;
|
||||
} SBProviderStruct;
|
||||
typedef SBProviderStruct* SBProvider;
|
||||
|
||||
typedef struct _HT_PaneStruct {
|
||||
struct _HT_PaneStruct *next;
|
||||
void *pdata;
|
||||
HT_Notification ns;
|
||||
PLHashTable *hash;
|
||||
HT_NotificationMask mask;
|
||||
RDF db;
|
||||
RDF_Notification rns;
|
||||
struct _HT_ViewStruct *viewList;
|
||||
struct _HT_ViewStruct *selectedView;
|
||||
struct _HT_URLSiteMapAssoc *smp;
|
||||
struct _HT_URLSiteMapAssoc *sbp;
|
||||
uint32 viewListCount;
|
||||
PRBool autoFlushFlag;
|
||||
SBProvider smartBrowsingProviders;
|
||||
PRBool dirty;
|
||||
PRBool personaltoolbar;
|
||||
PRBool toolbar;
|
||||
PRBool bookmarkmenu;
|
||||
PRBool special;
|
||||
int windowType;
|
||||
char *windowURL;
|
||||
char *templateType;
|
||||
struct _HT_PaneStruct *templatePane;
|
||||
char *htdburl;
|
||||
RDFT htdb;
|
||||
} HT_PaneStruct;
|
||||
|
||||
typedef struct HT_ColumnStruct {
|
||||
struct HT_ColumnStruct *next;
|
||||
char *name;
|
||||
uint32 width;
|
||||
uint32 tokenType;
|
||||
void *token;
|
||||
void *feData;
|
||||
PRBool isHiddenFlag;
|
||||
} HT_ColumnStruct, *HT_Column;
|
||||
|
||||
typedef struct _HT_ViewStruct {
|
||||
struct _HT_ViewStruct *next;
|
||||
HT_Pane pane;
|
||||
HT_Resource top;
|
||||
void *pdata;
|
||||
HT_Column columns;
|
||||
uint32 workspacePos;
|
||||
struct _HT_ResourceStruct ***itemList;
|
||||
uint32 itemListSize;
|
||||
uint32 itemListCount;
|
||||
uint32 topNodeIndex;
|
||||
uint32 selectedNodeHint;
|
||||
uint32 sortTokenType;
|
||||
void *sortToken;
|
||||
PRBool descendingFlag;
|
||||
PRBool refreshingItemListp;
|
||||
PRBool inited;
|
||||
RDF_Resource treeRel;
|
||||
} HT_ViewStruct;
|
||||
|
||||
typedef struct _HT_ValueStruct {
|
||||
struct _HT_ValueStruct *next;
|
||||
uint32 tokenType;
|
||||
RDF_Resource token;
|
||||
void *data;
|
||||
} HT_ValueStruct, *HT_Value;
|
||||
|
||||
#define HT_CONTAINER_FLAG 0x0001
|
||||
#define HT_OPEN_FLAG 0x0002
|
||||
#define HT_AUTOFLUSH_OPEN_FLAG 0x0004
|
||||
#define HT_HIDDEN_FLAG 0x0008
|
||||
#define HT_SELECTED_FLAG 0x0010
|
||||
#define HT_VOLATILE_URL_FLAG 0x0020
|
||||
#define HT_FREEICON_URL_FLAG 0x0040
|
||||
#define HT_PASSWORDOK_FLAG 0x0080
|
||||
#define HT_INITED_FLAG 0x0100
|
||||
#define HT_DIRTY_FLAG 0x0200
|
||||
#define HT_ENABLED_FLAG 0x0400
|
||||
|
||||
typedef struct _HT_ResourceStruct {
|
||||
struct _HT_ResourceStruct *nextItem;
|
||||
HT_View view;
|
||||
HT_Resource parent;
|
||||
RDF_Resource node;
|
||||
void *feData;
|
||||
char *dataSource;
|
||||
char *url[5];
|
||||
HT_Value values;
|
||||
HT_Resource child;
|
||||
HT_Resource *children; /* used by sorting */
|
||||
uint32 unsortedIndex; /* used by sorting */
|
||||
uint32 itemListIndex;
|
||||
uint32 numChildren, numChildrenTotal;
|
||||
uint16 flags;
|
||||
uint16 depth;
|
||||
HT_Resource next;
|
||||
/* a pane or view might have multiple occurances of a RDF_Resource.
|
||||
The hash table just points to the first of them. This allows us to
|
||||
make a linked list of it */
|
||||
} HT_ResourceStruct;
|
||||
|
||||
typedef struct _HT_MenuCommandStruct {
|
||||
struct _HT_MenuCommandStruct *next;
|
||||
HT_MenuCmd menuCmd;
|
||||
char *name;
|
||||
RDF_Resource graphCommand;
|
||||
} _HT_MenuCommandStruct, *HT_MenuCommand;
|
||||
|
||||
typedef struct _HT_CursorStruct {
|
||||
HT_Resource container;
|
||||
HT_Resource node;
|
||||
RDF_Cursor cursor;
|
||||
uint32 numElements;
|
||||
HT_Column columns;
|
||||
uint16 contextMenuIndex;
|
||||
PRBool foundValidMenuItem;
|
||||
PRBool isWorkspaceFlag;
|
||||
PRBool isBackgroundFlag;
|
||||
PRBool commandExtensions;
|
||||
PRBool commandListBuild;
|
||||
HT_MenuCmd menuCmd;
|
||||
HT_MenuCommand menuCommandList;
|
||||
} HT_CursorStruct;
|
||||
|
||||
typedef struct _HT_Icon {
|
||||
struct _HT_Icon *next;
|
||||
char *name;
|
||||
} _HT_Icon, *HT_Icon;
|
||||
|
||||
typedef struct _htmlElement {
|
||||
struct _htmlElement *next;
|
||||
HT_Resource node;
|
||||
RDF_Resource token;
|
||||
uint32 tokenType;
|
||||
} _htmlElement, *_htmlElementPtr;
|
||||
|
||||
typedef struct _HT_URLSiteMapAssoc {
|
||||
uint8 siteToolType;
|
||||
uint8 origin;
|
||||
uint8 onDisplayp;
|
||||
char *url;
|
||||
RDF_Resource sitemap;
|
||||
char* name;
|
||||
char* sitemapUrl;
|
||||
RDFT db;
|
||||
struct _HT_URLSiteMapAssoc *next;
|
||||
} HT_URLSiteMapAssoc;
|
||||
|
||||
|
||||
|
||||
/* HT function prototypes */
|
||||
|
||||
XP_BEGIN_PROTOS
|
||||
|
||||
void HT_Startup();
|
||||
void HT_Shutdown();
|
||||
void htLoadComplete(char *url, int status);
|
||||
void htTimerRoutine(void *timerID);
|
||||
PRBool possiblyUpdateView(HT_View view);
|
||||
void updateViewItem(HT_Resource node);
|
||||
HT_Resource newHTEntry (HT_View view, RDF_Resource node);
|
||||
void addWorkspace(HT_Pane pane, RDF_Resource r, void *feData);
|
||||
void deleteWorkspace(HT_Pane pane, RDF_Resource r);
|
||||
void htrdfNotifFunc (RDF_Event ns, void* pdata);
|
||||
void bmkNotifFunc (RDF_Event ns, void* pdata);
|
||||
void refreshItemListInt (HT_View view, HT_Resource node);
|
||||
PRBool relatedLinksContainerp (HT_Resource node);
|
||||
int nodeCompareRtn(HT_Resource *node1, HT_Resource *node2);
|
||||
void sortNodes(HT_View view, HT_Resource parent, HT_Resource *children, uint32 numChildren);
|
||||
uint32 refreshItemList1(HT_View view, HT_Resource node);
|
||||
void refreshItemList (HT_Resource node, HT_Event whatHappened);
|
||||
void refreshPanes();
|
||||
PRBool initToolbars (HT_Pane pane);
|
||||
HT_Pane paneFromResource(RDF db, RDF_Resource resource, HT_Notification notify, PRBool autoFlushFlag, PRBool autoOpenFlag, PRBool useColumns);
|
||||
void htSetBookmarkAddDateToNow(RDF_Resource r);
|
||||
RDF newHTPaneDB();
|
||||
RDF HTRDF_GetDB();
|
||||
PRBool initViews (HT_Pane pane);
|
||||
void htNewWorkspace(HT_Pane pane, char *id, char *optionalTitle, uint32 workspacePos);
|
||||
HT_PaneStruct * HT_GetHTPaneList ();
|
||||
HT_PaneStruct * HT_GetNextHTPane (HT_PaneStruct* pane);
|
||||
void htSetWorkspaceOrder(RDF_Resource src, RDF_Resource dest, PRBool afterDestFlag);
|
||||
HT_View HT_NewView (RDF_Resource topNode, HT_Pane pane, PRBool useColumns, void *feData, PRBool autoOpen);
|
||||
void sendNotification (HT_Resource node, HT_Event whatHappened, RDF_Resource s, HT_ColumnType type);
|
||||
void deleteHTNode(HT_Resource node);
|
||||
void destroyViewInt (HT_Resource r, PRBool saveOpenState);
|
||||
void htDeletePane(HT_Pane pane, PRBool saveWorkspaceOrder);
|
||||
void saveWorkspaceOrder(HT_Pane pane);
|
||||
void resynchItem (HT_Resource node, void *token, void *data, PRBool assertAction);
|
||||
void resynchContainer (HT_Resource container);
|
||||
HT_Resource addContainerItem (HT_Resource container, RDF_Resource item);
|
||||
void refreshContainerIndexes(HT_Resource container);
|
||||
void removeHTFromHash (HT_Pane pane, HT_Resource item);
|
||||
void deleteHTSubtree (HT_Resource subtree);
|
||||
void deleteContainerItem (HT_Resource container, RDF_Resource item);
|
||||
uint32 fillContainer (HT_Resource node);
|
||||
void sendColumnNotification (HT_View view, void *token, uint32 tokenType, HT_Event whatHappened);
|
||||
PRBool htIsMenuCmdEnabled(HT_Pane pane, HT_MenuCmd menuCmd, PRBool isWorkspaceFlag, PRBool isBackgroundFlag);
|
||||
void freeMenuCommandList();
|
||||
void exportCallbackWrite(PRFileDesc *fp, char *str);
|
||||
void exportCallback(MWContext *context, char *filename, RDF_Resource node);
|
||||
void htEmptyClipboard(RDF_Resource parent);
|
||||
void htCopyReference(RDF_Resource original, RDF_Resource newParent, PRBool empty);
|
||||
PRBool htVerifyUniqueToken(HT_Resource node, void *token, uint32 tokenType, char *data);
|
||||
PRBool ht_isURLReal(HT_Resource node);
|
||||
char * buildInternalIconURL(HT_Resource node, PRBool *volatileURLFlag, PRBool largeIconFlag, PRBool workspaceFlag);
|
||||
char * getIconURL( HT_Resource node, PRBool toolbarFlag, PRBool workspaceFlag, int state);
|
||||
PRBool htIsPropertyInMoreOptions(RDF_Resource r);
|
||||
void addHtmlElement(HT_Resource node, RDF_Resource token, uint32 tokenType);
|
||||
void freeHtmlElementList();
|
||||
_htmlElementPtr findHtmlElement(void *token);
|
||||
void freeHtmlElement(void *token);
|
||||
char * constructHTMLTagData(char *dynStr, int strID, char *data);
|
||||
char * constructHTML(char *dynStr, HT_Resource node, void *token, uint32 tokenType);
|
||||
char * constructHTMLPermission(char *dynStr, HT_Resource node, RDF_Resource token, char *permText);
|
||||
PRBool htIsOpLocked(HT_Resource node, RDF_Resource token);
|
||||
char * constructBasicHTML(char *dynStr, int strID, char *data1, char *data2);
|
||||
void setHiddenState (HT_Resource node);
|
||||
void htSetFindResourceName(RDF db, RDF_Resource r);
|
||||
void htOpenTo(HT_View view, RDF_Resource u, PRBool selectView);
|
||||
PRBool mutableContainerp (RDF_Resource node);
|
||||
char * possiblyCleanUpTitle (char* title);
|
||||
PRBool htRemoveChild(HT_Resource parent, HT_Resource child, PRBool moveToTrash);
|
||||
void ht_SetPassword(HT_Resource node, char *password);
|
||||
PRBool ht_hasPassword(HT_Resource node);
|
||||
PRBool ht_checkPassword(HT_Resource node, PRBool alwaysCheck);
|
||||
HT_DropAction htLaunchSmartNode(HT_Resource dropTarget, char *fullURL);
|
||||
HT_DropAction dropOnSmartNode(HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
||||
HT_DropAction dropOnSmartURL(HT_Resource dropTarget, char *objTitle, PRBool justAction);
|
||||
HT_DropAction dropOn (HT_Resource dropTarget, HT_Resource dropObject, PRBool justAction);
|
||||
void Win32FileCopyMove(HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction copyMoveRDFLink (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction copyMoveRDFLinkAtPos (HT_Resource dropx, HT_Resource dropObject, PRBool before);
|
||||
HT_DropAction uploadLFS (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction uploadRDFFile (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
HT_DropAction esfsCopyMoveContent (HT_Resource dropTarget, HT_Resource dropObject);
|
||||
RDF_BT urlResourceType (char* url);
|
||||
HT_DropAction dropURLOn (HT_Resource dropTarget, char* objURL, char *objTitle, PRBool justAction);
|
||||
void replacePipeWithColon(char* url);
|
||||
HT_DropAction copyRDFLinkURL (HT_Resource dropTarget, char* objURL, char *objTitle);
|
||||
HT_DropAction copyRDFLinkURLAt (HT_Resource dropx, char* objURL, char *objTitle, PRBool before);
|
||||
HT_DropAction uploadLFSURL (HT_Resource dropTarget, char* objURL);
|
||||
HT_DropAction uploadRDFFileURL (HT_Resource dropTarget, char* objURL);
|
||||
HT_DropAction esfsCopyMoveContentURL (HT_Resource dropTarget, char* objURL);
|
||||
RDFT HTADD(HT_Pane pane, RDF_Resource u, RDF_Resource s, void* v);
|
||||
HT_URLSiteMapAssoc * makeNewSMP (HT_Pane htPane, char* pUrl, char* sitemapurl);
|
||||
void RetainOldSitemaps (HT_Pane htPane, char *pUrl);
|
||||
void populateSBProviders (HT_Pane htPane);
|
||||
SBProvider SBProviderOfNode (HT_Resource node);
|
||||
PRBool implicitDomainURL (char* url);
|
||||
PRBool domainMatches (char *dom, char *url);
|
||||
void nextDomain (char* dom, size_t *n);
|
||||
PRBool relatedLinksEnabledURL (char* url);
|
||||
void cleanupInt (HT_Pane htPane, HT_URLSiteMapAssoc *nsmp, RDF_Resource parent);
|
||||
HT_Pane newTemplatePane(char* templateName);
|
||||
void PaneDeleteSBPCleanup (HT_Pane htPane);
|
||||
|
||||
#ifndef HT_RAPTOR
|
||||
PRBool rdfFindDialogHandler(XPDialogState *dlgstate, char **argv, int argc, unsigned int button);
|
||||
#endif
|
||||
|
||||
XP_END_PROTOS
|
||||
|
||||
#endif
|
||||
|
||||
404
mozilla/modules/rdf/src/jsec2rdf.c
Normal file
@@ -0,0 +1,404 @@
|
||||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
#include "jsec2rdf.h"
|
||||
#include "fs2rdf.h"
|
||||
#include "utils.h"
|
||||
#include "nlcstore.h"
|
||||
#include "vocabint.h"
|
||||
|
||||
NSPR_BEGIN_EXTERN_C
|
||||
|
||||
extern RDF gNCDB;
|
||||
RDF gJSecDB = NULL;
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_InitPrivilegeDB()
|
||||
{
|
||||
if (gJSecDB == 0) {
|
||||
gJSecDB = gNCDB;
|
||||
}
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SavePrivilegeDB()
|
||||
{
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_ClosePrivilegeDB()
|
||||
{
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
#define JSEC_PRINCIPAL_URL "jsecprin:"
|
||||
|
||||
char *
|
||||
RDFJSec_GetPrincipalURLString(char *principalID)
|
||||
{
|
||||
size_t size = RDF_STRLEN(principalID);
|
||||
char* url = getMem(size+RDF_STRLEN(JSEC_PRINCIPAL_URL)+1);
|
||||
if (url == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
sprintf(url, "%s%s", JSEC_PRINCIPAL_URL, principalID);
|
||||
strcpy(url, principalID);
|
||||
return url;
|
||||
}
|
||||
|
||||
RDF_Cursor
|
||||
RDFJSec_ListAllPrincipals()
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
if (gNavCenter != NULL) {
|
||||
c = RDF_GetSources(gJSecDB, gNavCenter->RDF_JSec,
|
||||
gNavCenter->RDF_JSecPrincipal,
|
||||
RDF_RESOURCE_TYPE, TRUE);
|
||||
}
|
||||
return(c);
|
||||
}
|
||||
|
||||
JSec_Principal
|
||||
RDFJSec_NextPrincipal(RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL) {
|
||||
return RDF_NextValue(c);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RDF_Error
|
||||
RDFJSec_ReleaseCursor(RDF_Cursor c)
|
||||
{
|
||||
RDF_Error err = 0;
|
||||
if (c != NULL) {
|
||||
err = RDF_DisposeCursor(c);
|
||||
}
|
||||
return (err);
|
||||
}
|
||||
|
||||
JSec_Principal
|
||||
RDFJSec_NewPrincipal(char* principalID)
|
||||
{
|
||||
RDF_Resource principalUnit;
|
||||
char *url = RDFJSec_GetPrincipalURLString(principalID);
|
||||
if (url == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
principalUnit = RDF_GetResource(NULL, url, FALSE);
|
||||
if (!principalUnit) {
|
||||
principalUnit = RDF_GetResource(NULL, url, TRUE);
|
||||
}
|
||||
freeMem(url);
|
||||
return (JSec_Principal)principalUnit;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipal(JSec_Principal pr)
|
||||
{
|
||||
if ((pr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
if (RDF_HasAssertion(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec,
|
||||
RDF_RESOURCE_TYPE, PR_FALSE)) {
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
setContainerp(pr, PR_TRUE);
|
||||
setResourceType(pr, JSEC_RT);
|
||||
RDF_Assert(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipal(JSec_Principal pr)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
if ((pr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Before deleting the principal, delete all the PrincipalUses for this principal.
|
||||
*/
|
||||
c = RDFJSec_ListAllPrincipalUses(pr);
|
||||
if (c != NULL) {
|
||||
JSec_PrincipalUse prUse;
|
||||
while ((prUse = RDFJSec_NextPrincipalUse(c)) != NULL) {
|
||||
RDFJSec_DeletePrincipalUse(pr, prUse);
|
||||
}
|
||||
}
|
||||
RDF_Unassert(gJSecDB, pr, gNavCenter->RDF_JSecPrincipal, gNavCenter->RDF_JSec, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_PrincipalID(JSec_Principal pr)
|
||||
{
|
||||
char *url = resourceID(pr);
|
||||
char *ans = getMem(RDF_STRLEN(url)+1);
|
||||
int n;
|
||||
if (ans == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
n = charSearch(':', url);
|
||||
if (n == -1) {
|
||||
strcpy(ans, url);
|
||||
} else {
|
||||
strcpy(ans, url+n+1);
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
void *
|
||||
RDFJSec_AttributeOfPrincipal(JSec_Principal pr, char* attributeType)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
void *attValue;
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetTargets(gJSecDB, pr, attributeResource, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
attValue = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return attValue;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SetPrincipalAttribute(JSec_Principal pr, char* attributeType, void* attValue)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
RDF_Assert(gJSecDB, pr, attributeResource, attValue, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
RDFJSec_ListAllPrincipalUses(JSec_Principal pr)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetSources(gJSecDB, (RDF_Resource)pr, gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, true);
|
||||
return(c);
|
||||
}
|
||||
|
||||
JSec_PrincipalUse
|
||||
RDFJSec_NextPrincipalUse(RDF_Cursor c)
|
||||
{
|
||||
if (c != NULL) {
|
||||
return RDF_NextValue(c);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
JSec_PrincipalUse
|
||||
RDFJSec_NewPrincipalUse(JSec_Principal pr, JSec_Target tr, char* priv)
|
||||
{
|
||||
RDF_Resource principalUseUnit;
|
||||
char *targetID = resourceID(tr);
|
||||
char *principalID = resourceID(pr);
|
||||
char *principalUseID = getMem(RDF_STRLEN(principalID) + strlen(targetID) + 2);
|
||||
if (principalUseID == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
sprintf(principalUseID, "%s!%s", principalID, targetID);
|
||||
principalUseUnit = RDF_GetResource(NULL, principalUseID, FALSE);
|
||||
if (!principalUseUnit) {
|
||||
principalUseUnit = RDF_GetResource(NULL, principalUseID, TRUE);
|
||||
RDFJSec_AddTargetToPrincipalUse(principalUseUnit, tr);
|
||||
RDFJSec_AddPrincipalUsePrivilege(principalUseUnit, priv);
|
||||
}
|
||||
return principalUseUnit;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipalUse(JSec_Principal pr, JSec_PrincipalUse prUse)
|
||||
{
|
||||
if ((pr == NULL) || (prUse == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
setContainerp(prUse, PR_TRUE);
|
||||
setResourceType(prUse, JSEC_RT);
|
||||
RDF_Assert(gJSecDB, prUse, gCoreVocab->RDF_parent, pr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipalUse (JSec_Principal pr, JSec_PrincipalUse prUse)
|
||||
{
|
||||
JSec_Target tr;
|
||||
char *priv;
|
||||
if ((pr == NULL) || (prUse == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Before deleting the principal, delete all the PrincipalUses for this principal.
|
||||
*/
|
||||
tr = RDFJSec_TargetOfPrincipalUse(prUse);
|
||||
RDFJSec_DeleteTargetToPrincipalUse(prUse, tr);
|
||||
priv = RDFJSec_PrivilegeOfPrincipalUse(prUse);
|
||||
RDFJSec_DeletePrincipalUsePrivilege(prUse, priv);
|
||||
RDF_Unassert(gJSecDB, prUse, gCoreVocab->RDF_parent, pr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
const char *
|
||||
RDFJSec_PrincipalUseID(JSec_PrincipalUse prUse)
|
||||
{
|
||||
return resourceID(prUse);
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddPrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv)
|
||||
{
|
||||
char *oldPriv;
|
||||
if ((prUse == NULL) || (priv == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Each PrincipalUse can only have one Privilege. Thus delete the old privilege*/
|
||||
oldPriv = RDFJSec_PrivilegeOfPrincipalUse(prUse);
|
||||
RDFJSec_DeletePrincipalUsePrivilege(prUse, oldPriv);
|
||||
RDF_Assert(gJSecDB, prUse, gNavCenter->RDF_JSecAccess, priv, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeletePrincipalUsePrivilege (JSec_PrincipalUse prUse, char* priv)
|
||||
{
|
||||
if ((prUse == NULL) || (priv == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
RDF_Unassert(gJSecDB, prUse, gNavCenter->RDF_JSecAccess, priv, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_PrivilegeOfPrincipalUse (JSec_PrincipalUse prUse)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
char *privilege;
|
||||
if (gNavCenter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
c = RDF_GetTargets(gJSecDB, (RDF_Resource)prUse, gNavCenter->RDF_JSecAccess, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
privilege = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return privilege;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_AddTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr)
|
||||
{
|
||||
JSec_Target oldTarget;
|
||||
if ((prUse == NULL) || (tr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
/* Each PrincipalUse can only have one Target. Thus delete the old target */
|
||||
oldTarget = RDFJSec_TargetOfPrincipalUse(prUse);
|
||||
RDFJSec_DeleteTargetToPrincipalUse(prUse, oldTarget);
|
||||
RDF_Assert(gJSecDB, prUse, gNavCenter->RDF_JSecTarget, tr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_DeleteTargetToPrincipalUse(JSec_PrincipalUse prUse, JSec_Target tr)
|
||||
{
|
||||
if ((prUse == NULL) || (tr == NULL) || (gNavCenter == NULL)) {
|
||||
return JSec_NullObject;
|
||||
}
|
||||
RDF_Unassert(gJSecDB, prUse, gNavCenter->RDF_JSecTarget, tr, RDF_RESOURCE_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
JSec_Target
|
||||
RDFJSec_TargetOfPrincipalUse (JSec_PrincipalUse prUse)
|
||||
{
|
||||
RDF_Cursor c = NULL;
|
||||
JSec_Target tr;
|
||||
if ((prUse == NULL) || (gNavCenter == NULL)) {
|
||||
return NULL;
|
||||
}
|
||||
c = RDF_GetTargets(gJSecDB, (RDF_Resource)prUse, gNavCenter->RDF_JSecTarget, RDF_RESOURCE_TYPE, true);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
tr = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return tr;
|
||||
}
|
||||
|
||||
JSec_Target
|
||||
RDFJSec_NewTarget(char* targetName, JSec_Principal pr)
|
||||
{
|
||||
RDF_Resource tr;
|
||||
/* RDF_Resource prResource; */
|
||||
char *principalID = RDFJSec_PrincipalID(pr);
|
||||
char *targetID = getMem(RDF_STRLEN(targetName) + strlen(principalID) + 2);
|
||||
if (targetID == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (gNavCenter == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sprintf(targetID, "%s!%s", targetName, principalID);
|
||||
tr = RDF_GetResource(NULL, targetID, FALSE);
|
||||
if (!tr) {
|
||||
tr = RDF_GetResource(NULL, targetID, TRUE);
|
||||
if (tr == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
RDFJSec_SetTargetAttribute(tr, "targetName", targetName);
|
||||
RDF_Assert(gJSecDB, tr, gNavCenter->RDF_JSecPrincipal, pr, RDF_RESOURCE_TYPE);
|
||||
}
|
||||
return tr;
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_GetTargetName(JSec_Target tr)
|
||||
{
|
||||
return RDFJSec_AttributeOfTarget(tr, "targetName");
|
||||
}
|
||||
|
||||
char *
|
||||
RDFJSec_AttributeOfTarget(JSec_Target tr, char* attributeType)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
char *attValue;
|
||||
RDF_Cursor c = NULL;
|
||||
c = RDF_GetTargets(gJSecDB, tr, attributeResource, RDF_STRING_TYPE, TRUE);
|
||||
if (c == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
attValue = RDF_NextValue(c);
|
||||
RDF_DisposeCursor(c);
|
||||
return attValue;
|
||||
}
|
||||
|
||||
JSec_Error
|
||||
RDFJSec_SetTargetAttribute(JSec_Target tr, char* attributeType, char* attValue)
|
||||
{
|
||||
RDF_Resource attributeResource = RDF_GetResource(NULL, attributeType, TRUE);
|
||||
RDF_Assert(gJSecDB, tr, attributeResource, attValue, RDF_STRING_TYPE);
|
||||
return JSec_OK;
|
||||
}
|
||||
|
||||
NSPR_END_EXTERN_C
|
||||
562
mozilla/modules/rdf/src/ldap2rdf.c
Normal file
@@ -0,0 +1,562 @@
|
||||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
||||
*
|
||||
* The contents of this file are subject to the Netscape Public License
|
||||
* Version 1.0 (the "NPL"); you may not use this file except in
|
||||
* compliance with the NPL. You may obtain a copy of the NPL at
|
||||
* http://www.mozilla.org/NPL/
|
||||
*
|
||||
* Software distributed under the NPL is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
|
||||
* for the specific language governing rights and limitations under the
|
||||
* NPL.
|
||||
*
|
||||
* The Initial Developer of this code under the NPL is Netscape
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
|
||||
* Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
This file implements LDAP support for the rdf data model.
|
||||
For more information on this file, contact rjc or guha
|
||||
For more information on RDF, look at the RDF section of www.mozilla.org
|
||||
*/
|
||||
|
||||
/*
|
||||
XXX Someone needs to get this up to speed again
|
||||
*/
|
||||
#if 0
|
||||
#ifdef MOZ_LDAP
|
||||
|
||||
#include "ldap2rdf.h"
|
||||
#include "utils.h"
|
||||
|
||||
/* statics */
|
||||
static PRHashTable *ldap2rdfHash;
|
||||
static PRHashTable *invldap2rdfHash;
|
||||
static RDFT gRDFDB;
|
||||
static PRBool ldap2rdfInitedp = 0;
|
||||
|
||||
|
||||
|
||||
RDFT
|
||||
MakeLdapStore (char* url)
|
||||
{
|
||||
RDFT ntr = (RDFT)getMem(sizeof(RDF_TranslatorStruct));
|
||||
ntr->assert = ldapAssert;
|
||||
ntr->unassert = ldapUnassert;
|
||||
ntr->getSlotValue = ldapGetSlotValue;
|
||||
ntr->getSlotValues = ldapGetSlotValues;
|
||||
ntr->hasAssertion = ldapHasAssertion;
|
||||
ntr->nextValue = ldapNextValue;
|
||||
ntr->disposeCursor = ldapDisposeCursor;
|
||||
ldap2rdfInit(ntr);
|
||||
return ntr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
LdapInit (RDFT ntr)
|
||||
{
|
||||
ntr->assert = ldapAssert;
|
||||
ntr->unassert = ldapUnassert;
|
||||
ntr->getSlotValue = ldapGetSlotValue;
|
||||
ntr->getSlotValues = ldapGetSlotValues;
|
||||
ntr->hasAssertion = ldapHasAssertion;
|
||||
ntr->nextValue = ldapNextValue;
|
||||
ntr->disposeCursor = ldapDisposeCursor;
|
||||
ldap2rdfInit(ntr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ldap2rdfInit (RDFT rdf)
|
||||
{
|
||||
if (!ldap2rdfInitedp) {
|
||||
ldap2rdfHash = PR_NewHashTable(500, idenHash, idenEqual, idenEqual, null, null);
|
||||
invldap2rdfHash = PR_NewHashTable(500, idenHash, idenEqual, idenEqual, null, null);
|
||||
gRDFDB = rdf;
|
||||
ldap2rdfInitedp = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
ldaparg1 (RDF_Resource u)
|
||||
{
|
||||
return (Assertion) PR_HashTableLookup(ldap2rdfHash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
setldaparg1 (RDF_Resource u, Assertion as)
|
||||
{
|
||||
return (Assertion) PR_HashTableAdd(ldap2rdfHash, u, as);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
ldaparg2 (RDF_Resource u)
|
||||
{
|
||||
return (Assertion) PR_HashTableLookup(invldap2rdfHash, u);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Assertion
|
||||
setldaparg2 (RDF_Resource u, Assertion as)
|
||||
{
|
||||
return (Assertion) PR_HashTableAdd(invldap2rdfHash, u, as);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapAssert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(tv) && (ldapContainerp(v))) {
|
||||
return (ldapAddChild(rdf, (RDF_Resource)v, u));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapUnassert (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v,
|
||||
RDF_ValueType type)
|
||||
{
|
||||
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
if ((s == gCoreVocab->RDF_parent) && (type == RDF_RESOURCE_TYPE) &&
|
||||
(ldapContainerp(v))) {
|
||||
return (ldapRemoveChild(rdf, (RDF_Resource)v, u));
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapDBAdd (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, newAs;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if ((s == gCoreVocab->RDF_instanceOf) && (v == gWebData->RDF_Container)) {
|
||||
setContainerp(u, true);
|
||||
return 1;
|
||||
}
|
||||
|
||||
nextAs = prevAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) return 1;
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
newAs = makeNewAssertion(u, s, v, type, 1);
|
||||
if (prevAs == null) {
|
||||
setldaparg1(u, newAs);
|
||||
} else {
|
||||
prevAs->next = newAs;
|
||||
}
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ldaparg2((RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
if (prevAs == null) {
|
||||
setldaparg2((RDF_Resource)v, newAs);
|
||||
} else {
|
||||
prevAs->invNext = newAs;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_ASSERT_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapDBRemove (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type)
|
||||
{
|
||||
Assertion nextAs, prevAs, ans;
|
||||
PRBool found = false;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
nextAs = prevAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type)) {
|
||||
if (prevAs == null) {
|
||||
setldaparg1(u, nextAs->next);
|
||||
} else {
|
||||
prevAs->next = nextAs->next;
|
||||
}
|
||||
found = true;
|
||||
ans = nextAs;
|
||||
break;
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
if (found == false) return false;
|
||||
if (type == RDF_RESOURCE_TYPE) {
|
||||
nextAs = prevAs = ldaparg2((RDF_Resource)v);
|
||||
while (nextAs != null) {
|
||||
if (nextAs == ans) {
|
||||
if (prevAs == nextAs) {
|
||||
setldaparg2((RDF_Resource)v, nextAs->invNext);
|
||||
} else {
|
||||
prevAs->invNext = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
prevAs = nextAs;
|
||||
nextAs = nextAs->invNext;
|
||||
}
|
||||
}
|
||||
sendNotifications2(rdf, RDF_DELETE_NOTIFY, u, s, v, type, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapHasAssertion (RDFT rdf, RDF_Resource u, RDF_Resource s, void* v, RDF_ValueType type, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )v)));
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
|
||||
nextAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
|
||||
possiblyAccessldap(rdf, u, s, false);
|
||||
|
||||
nextAs = ldaparg1(u);
|
||||
while (nextAs != null) {
|
||||
if (asEqual(nextAs, u, s, v, type) && (nextAs->tv == tv)) return true;
|
||||
nextAs = nextAs->next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ldapGetSlotValue (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion nextAs;
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
|
||||
possiblyAccessldap(rdf, u, s, inversep);
|
||||
|
||||
nextAs = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
while (nextAs != null) {
|
||||
if ((nextAs->s == s) && (nextAs->tv == tv) && (nextAs->type == type)) {
|
||||
void * retVal = (inversep ? nextAs->u : nextAs->value);
|
||||
PR_ASSERT( (RDF_STRING_TYPE != type) || ( IsUTF8String((const char* )retVal)));
|
||||
return retVal
|
||||
}
|
||||
nextAs = (inversep ? nextAs->invNext : nextAs->next);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Cursor
|
||||
ldapGetSlotValues (RDFT rdf, RDF_Resource u, RDF_Resource s, RDF_ValueType type, PRBool inversep, PRBool tv)
|
||||
{
|
||||
Assertion as;
|
||||
RDF_Cursor c;
|
||||
if (!ldap2rdfInitedp) ldap2rdfInit(rdf);
|
||||
as = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
if (as == null) {
|
||||
possiblyAccessldap(rdf, u, s, inversep);
|
||||
as = (inversep ? ldaparg2(u) : ldaparg1(u));
|
||||
if (as == null)
|
||||
return null;
|
||||
}
|
||||
c = (RDF_CursorStruc*)getMem(sizeof(RDF_CursorStruc));
|
||||
c->u = u;
|
||||
c->s = s;
|
||||
c->type = type;
|
||||
c->inversep = inversep;
|
||||
c->tv = tv;
|
||||
c->count = 0;
|
||||
c->pdata = as;
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void *
|
||||
ldapNextValue (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
while (c->pdata != null) {
|
||||
Assertion as = (Assertion) c->pdata;
|
||||
if ((as->s == c->s) && (as->tv == c->tv) && (c->type == as->type)) {
|
||||
c->value = (c->inversep ? as->u : as->value);
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
return c->value;
|
||||
}
|
||||
c->pdata = (c->inversep ? as->invNext : as->next);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Error
|
||||
ldapDisposeCursor (RDFT mcf, RDF_Cursor c)
|
||||
{
|
||||
freeMem(c);
|
||||
return noRDFErr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
RDF_Resource
|
||||
ldapNewContainer(char *id)
|
||||
{
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
ldapModifyEntry (RDFT rdf, RDF_Resource parent, RDF_Resource child, PRBool addFlag)
|
||||
{
|
||||
RDF_Cursor c;
|
||||
RDF_Resource newParent, r;
|
||||
char *urivals[2];
|
||||
LDAP *ld;
|
||||
LDAPMod urimod, *mods[2];
|
||||
LDAPURLDesc *ldURL=NULL;
|
||||
int err;
|
||||
char *errStr, *parentID;
|
||||
|
||||
parentID = resourceID(parent);
|
||||
|
||||
if (containerp(child))
|
||||
{
|
||||
if (newParent = ldapNewContainer(parentID))
|
||||
{
|
||||
if ((c = RDF_GetSources(rdf->rdf->rdf, child,
|
||||
gCoreVocab->RDF_parent, RDF_RESOURCE_TYPE, 1)) != NULL)
|
||||
{
|
||||
while ((r = RDF_NextValue(c)) != NULL)
|
||||
{
|
||||
err = ldapModifyEntry(rdf, newParent, r, addFlag);
|
||||
if (err)
|
||||
{
|
||||
/* XXX MAJOR rollback issues!
|
||||
Punt for now! */
|
||||
|
||||
return(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
|
||||
ldap_url_parse(parentID, &ldURL);
|
||||
if (ldURL == NULL) return(-1);
|
||||
ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
|
||||
if (ld == NULL)
|
||||
{
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(-1);
|
||||
}
|
||||
if ((err = ldap_simple_bind_s(ld, ADMIN_ID, ADMIN_PW)) /* XXX */
|
||||
!= LDAP_SUCCESS)
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(-1);
|
||||
}
|
||||
|
||||
urivals[0] = resourceID(child);
|
||||
urivals[1] = NULL;
|
||||
|
||||
urimod.mod_op = ((addFlag == true) ? LDAP_MOD_ADD : LDAP_MOD_DELETE);
|
||||
urimod.mod_type = "labeledURI";
|
||||
urimod.mod_values = urivals;
|
||||
|
||||
mods[0] = &urimod;
|
||||
mods[1] = NULL;
|
||||
|
||||
err = ldap_modify_s(ld, ldURL->lud_dn, mods);
|
||||
if (err != LDAP_SUCCESS)
|
||||
{
|
||||
if ((errStr = ldap_err2string(err)) != NULL)
|
||||
{
|
||||
/* We need to change XP_MakeHTMLAlert to use UTF8 */
|
||||
XP_MakeHTMLAlert(NULL, errStr);
|
||||
}
|
||||
}
|
||||
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapAddChild (RDFT rdf, RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
return (ldapModifyEntry(rdf, parent, child, true) != LDAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapRemoveChild (RDFT rdf, RDF_Resource parent, RDF_Resource child)
|
||||
{
|
||||
return (ldapModifyEntry(rdf, parent, child, false) != LDAP_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
possiblyAccessldap(RDFT rdf, RDF_Resource u, RDF_Resource s, PRBool inversep)
|
||||
{
|
||||
/** try to get the values of u.s from the directory **/
|
||||
|
||||
LDAP *ld;
|
||||
LDAPMessage *result=NULL, *entry;
|
||||
LDAPURLDesc *ldURL=NULL;
|
||||
RDF_Resource node;
|
||||
char *attrs[2], **vals;
|
||||
int err, i;
|
||||
char *title = NULL;
|
||||
|
||||
/*
|
||||
Note: a labeledURI is a url followed by an optional [space title-string]
|
||||
*/
|
||||
|
||||
if (!stringEquals(resourceID(s), resourceID(gCoreVocab->RDF_parent)) || (!inversep) || (!ldap_is_ldap_url(resourceID(u)))) return;
|
||||
|
||||
ldap_url_parse(resourceID(u), &ldURL);
|
||||
if (ldURL == NULL) return;
|
||||
ld = ldap_init (ldURL->lud_host, ldURL->lud_port);
|
||||
if (ld == NULL)
|
||||
{
|
||||
ldap_free_urldesc(ldURL);
|
||||
return;
|
||||
}
|
||||
if ((err = ldap_simple_bind_s(ld, NULL, NULL)) != LDAP_SUCCESS)
|
||||
{
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
return;
|
||||
}
|
||||
|
||||
attrs[0] = "labeledURI";
|
||||
attrs[1] = NULL;
|
||||
|
||||
err = ldap_search_s(ld, ldURL->lud_dn, LDAP_SCOPE_BASE, ldURL->lud_filter, attrs, 0, &result);
|
||||
if (err == LDAP_SUCCESS)
|
||||
{
|
||||
for (entry=ldap_first_entry(ld, result); entry!=NULL; entry=ldap_next_entry(ld, entry))
|
||||
{
|
||||
if ((vals = ldap_get_values(ld, entry, attrs[0])) != NULL)
|
||||
{
|
||||
for (i=0; vals[i] != NULL; i++)
|
||||
{
|
||||
/* vals[i] has a URL... add into RDF graph */
|
||||
|
||||
/*
|
||||
if (((title = strstr(vals[i], " ")) != NULL)
|
||||
&& (*(title+1) != '\0'))
|
||||
{
|
||||
*(++title) = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
title = NULL;
|
||||
}
|
||||
*/
|
||||
if ((node = RDF_Create(vals[i], true)) != NULL)
|
||||
{
|
||||
setResourceType(node, LDAP_RT);
|
||||
if (ldapContainerp(node) == true)
|
||||
{
|
||||
setContainerp(node, 1);
|
||||
}
|
||||
|
||||
ldapDBAdd(rdf, node, gCoreVocab->RDF_parent,
|
||||
u, RDF_RESOURCE_TYPE);
|
||||
|
||||
if (title != NULL)
|
||||
{
|
||||
ldapDBAdd(rdf, node, gCoreVocab->RDF_name,
|
||||
title, RDF_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
ldap_value_free(vals);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (result != NULL)
|
||||
{
|
||||
ldap_msgfree(result);
|
||||
}
|
||||
ldap_unbind(ld);
|
||||
ldap_free_urldesc(ldURL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
PRBool
|
||||
ldapContainerp (RDF_Resource u)
|
||||
{
|
||||
return(ldap_is_ldap_url(resourceID(u))); /* XXX ??? */
|
||||
}
|
||||
|
||||
|
||||
#endif /* MOZ_LDAP */
|
||||
#endif
|
||||
|
||||