fix for bug #192074. remove the absync code from the mozilla tree.

r=cavin, sr=bienvenu, a=asa


git-svn-id: svn://10.0.0.236/trunk@137656 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
sspitzer%netscape.com 2003-02-11 08:14:50 +00:00
parent 460fb44232
commit 001d7a514b
38 changed files with 1 additions and 10066 deletions

View File

@ -26,7 +26,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public base db/msgdb news local mime compose imap addrbook import absync extensions
DIRS = public base db/msgdb news local mime compose imap addrbook import extensions
ifeq ($(OS_ARCH),WINNT)
DIRS += mapi

View File

@ -1,32 +0,0 @@
#
# 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):
#
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
DIRS = public src build
include $(topsrcdir)/config/rules.mk

View File

@ -1,21 +0,0 @@
# 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):
#
nsAbSyncCID.h

View File

@ -1,69 +0,0 @@
#
# 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):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
LIBRARY_NAME = absyncsvc
META_COMPONENT = mail
EXPORT_LIBRARY = 1
IS_COMPONENT = 1
MODULE_NAME = nsAbSyncModule
SHORT_LIBNAME = absyncsv
REQUIRES = xpcom \
string \
necko \
docshell \
uriloader \
msgbase \
intl \
addrbook \
mork \
$(NULL)
ifeq ($(USE_SHORT_LIBNAME),1)
EXTRA_DSO_LIBS = msgbsutl
else
EXTRA_DSO_LIBS = msgbaseutil
endif
CPPSRCS = nsAbSyncFactory.cpp
EXPORTS = nsAbSyncCID.h
SHARED_LIBRARY_LIBS = \
$(DIST)/lib/$(LIB_PREFIX)absync_s.$(LIB_SUFFIX) \
$(NULL)
EXTRA_DSO_LDOPTS = \
$(LIBS_DIR) \
$(EXTRA_DSO_LIBS) \
$(MOZ_UNICHARUTIL_LIBS) \
$(MOZ_JS_LIBS) \
$(MOZ_COMPONENT_LIBS) \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,101 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAbSyncCID_h__
#define nsAbSyncCID_h__
#include "nsISupports.h"
#include "nsIFactory.h"
#include "nsIComponentManager.h"
//
// Ab Sync Service
//
#define NS_ABSYNC_SERVICE_CID \
{ /* {3C21BB39-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb39, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_SERVICE_CONTRACTID \
"@mozilla.org/absync;1"
//
// Ab Sync Listener
//
#define NS_ABSYNC_LISTENER_CID \
{ /* {3C21BB44-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb44, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_LISTENER_CONTRACTID \
"@mozilla.org/absync/listener;1"
//
// Ab Sync Post Engine
//
#define NS_ABSYNC_POST_ENGINE_CID \
{ /* {3C21BB9f-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bb9f, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_POST_ENGINE_CONTRACTID \
"@mozilla.org/absync/postengine;1"
//
// Ab Sync Post Listener
//
#define NS_ABSYNC_POST_LISTENER_CID \
{ /* {3C21BBcc-0A87-11d4-8FD6-00A024A7D144} */ \
0x3c21bbcc, 0xa87, 0x11d4, \
{ 0x8f, 0xd6, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } }
#define NS_ABSYNC_POST_LISTENER_CONTRACTID \
"@mozilla.org/absync/postlistener;1"
//
// Sync Driver
//
#define NS_ADDBOOK_SYNCDRIVER_CONTRACTID \
"@mozilla.org/addressbook/services/syncdriver;1"
#define NS_ADDBOOK_SYNCDRIVER_CID \
{ /* 40D1D3DA-1637-11d4-8FE1-00A024A7D144 */ \
0x40d1d3da, 0x1637, 0x11d4, \
{ 0x8f, 0xe1, 0x0, 0xa0, 0x24, 0xa7, 0xd1, 0x44 } \
}
#endif // nsAbSyncCID_h__

View File

@ -1,79 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "msgCore.h"
#include "nsISupports.h"
#include "nsCOMPtr.h"
#include "nsIFactory.h"
#include "nsIGenericFactory.h"
#include "nsIServiceManager.h"
#include "nsIModule.h"
#include "pratom.h"
#include "nsAbSyncCID.h"
/* Include all of the interfaces our factory can generate components for */
#include "nsAbSync.h"
#include "nsAbSyncPostEngine.h"
#include "nsABSyncDriver.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbSync);
NS_GENERIC_FACTORY_CONSTRUCTOR(nsAbSyncDriver)
////////////////////////////////////////////////////////////
//
////////////////////////////////////////////////////////////
static const nsModuleComponentInfo components[] =
{
{ "Addressbook Sync",
NS_ABSYNC_SERVICE_CID,
NS_ABSYNC_SERVICE_CONTRACTID,
nsAbSyncConstructor },
{ "Addressbook Sync Post Engine",
NS_ABSYNC_POST_ENGINE_CID,
NS_ABSYNC_POST_ENGINE_CONTRACTID,
nsAbSyncPostEngine::Create },
{ "The Address Book Sync Driver",
NS_ADDBOOK_SYNCDRIVER_CID,
NS_ADDBOOK_SYNCDRIVER_CONTRACTID,
nsAbSyncDriverConstructor }
};
NS_IMPL_NSGETMODULE(nsAbSyncModule, components)

View File

@ -1 +0,0 @@
_NSGetModule ; 1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,25 +0,0 @@
/* -*- 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.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):
*/
#include "MacPrefix.h"

View File

@ -1,25 +0,0 @@
/* -*- 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.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):
*/
#include "MacPrefix_debug.h"

View File

@ -1,42 +0,0 @@
#
# 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):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
XPIDL_MODULE = absync
XPIDLSRCS = \
nsIAbSync.idl \
nsIAbSyncMojo.idl \
nsIAbSyncListener.idl \
nsIAbSyncPostEngine.idl \
nsIAbSyncPostListener.idl \
nsIAbSyncDriver.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

View File

@ -1,69 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsrootidl.idl"
#include "nsIAbSyncListener.idl"
#include "nsIMsgStatusFeedback.idl"
[uuid(3c9cbef8-070b-4123-98b2-9297443a8cd1)]
interface nsIAbSyncState
{
const long nsIAbSyncIdle = 0;
const long nsIAbSyncRunning = 1;
};
[scriptable, uuid(74872D27-0A4E-11d4-8FD6-00A024A7D144)]
interface nsIAbSync : nsISupports {
/*
* This is the primary interface for performing AB Sync operations
*/
/* Add or remove a listener for this particular sync operation */
void AddSyncListener(in nsIAbSyncListener aListener);
void RemoveSyncListener(in nsIAbSyncListener aListener);
/* Get the nsIAbSyncPostEngineState of the sync operation */
PRInt32 GetCurrentState();
/*
* Send the protocol request and get a transaction ID in return that
* will be sent along with all sync listener operations
*/
void PerformAbSync(in nsIDOMWindowInternal aDOMWindow, out PRInt32 aTransactionID);
void CancelAbSync();
void SetAbSyncUser(in string aUser);
};

View File

@ -1,48 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsrootidl.idl"
#include "nsIAbSyncListener.idl"
#include "nsIMsgStatusFeedback.idl"
[scriptable, uuid(91FDFEE1-EFBC-11d3-8F97-000073757374)]
interface nsIAbSyncDriver : nsIAbSyncListener
{
void KickIt(in nsIMsgStatusFeedback aStatus, in nsIDOMWindowInternal aDOMWindow);
void CancelIt();
};

View File

@ -1,96 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
%{C++
%}
[scriptable, uuid(E0ED29E0-098A-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncListener : nsISupports {
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
void OnStartAuthOperation();
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
void OnStopAuthOperation(in nsresult aStatus, in wstring aMsg, in string aCookie);
/**
* Notify the observer that the AB Sync operation has begun. This method is
* called only once, at the beginning of a sync transaction
*
*/
void OnStartOperation(in PRInt32 aTransactionID, in PRUint32 aMsgSize);
/**
* Notify the observer that progress as occurred for the AB Sync operation
*/
void OnProgress(in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax);
/**
* Notify the observer with a status message for sync operation
*/
void OnStatus(in PRInt32 aTransactionID, in wstring aMsg);
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
*/
void OnStopOperation(in PRInt32 aTransactionID, in nsresult aStatus,
in wstring aMsg);
};

View File

@ -1,62 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIStreamListener.idl"
#include "nsIDocShell.idl"
%{C++
#define NS_AB_SYNC_MOJO_CID \
{ 0x842cc263, 0x5255, 0x1144, \
{ 0xcc, 0xb8, 0x44, 0x45, 0x53, 0xff, 0x0, 0x2 } }
#define NS_AB_SYNC_MOJO_CONTRACTID \
"@mozilla.org/absync/absyncmojo;1"
%}
[scriptable, uuid(74872D27-0A4E-11d4-8FD6-BEEF24A7D144)]
interface nsIAbSyncMojo : nsISupports {
/*
* This is the primary interface for performing AB Sync mojo operations
*/
string BuildMojoString(in nsIDocShell aRootDocShell);
void StartAbSyncMojo(in nsIStreamListener aListener,
in nsIDocShell aRootDocShell,
in string aUser);
void GetAbSyncMojoResults(out string aMojoUser, out string aMojoString,
out string aMojoSpec, out long aMojoPort);
void CancelTheMojo();
};

View File

@ -1,76 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsIAbSyncPostListener.idl"
#include "nsIDocShell.idl"
[scriptable, uuid(E0ED29D3-BEEF-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncPostEngineState
{
const long nsIAbSyncPostIdle = 0;
const long nsIAbSyncPostRunning = 1;
const long nsIAbSyncAuthenticationRunning = 2;
};
[scriptable, uuid(E0ED29D3-098A-11d4-8FD6-00A024A7D144)]
interface nsIAbSyncPostEngine : nsISupports {
/*
* This is the primary interface for posting operations to the
* Address Book server in the sky
*/
/* Add or remove a listener for this particular sync operation */
void AddPostListener(in nsIAbSyncPostListener aListener);
void RemovePostListener(in nsIAbSyncPostListener aListener);
/* Get the nsIAbSyncPostEngineState of the sync operation */
string BuildMojoString(in nsIDocShell aRootDocShell);
PRInt32 GetCurrentState();
void GetMojoUserAndSnack(out string aMojoUser, out string aMojoSnack);
/*
* Send the protocol request and get a transaction ID in return that
* will be sent along with all sync listener operations
*/
void SendAbRequest(in string aSpec, in PRInt32 aPort, in string aProtocolRequest, in PRInt32 aTransactionID,
in nsIDocShell aDocShell, in string aUser);
/*
* Cancel it!
*/
void CancelAbSync();
};

View File

@ -1,99 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsISupports.idl"
#include "nsrootidl.idl"
%{C++
%}
[scriptable, uuid(E0ED29E0-098A-11d4-8FD6-00A024A7BEEF)]
interface nsIAbSyncPostListener : nsISupports {
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
void OnStartAuthOperation();
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
void OnStopAuthOperation(in nsresult aStatus, in wstring aMsg, in string aCookie);
/**
* Notify the observer that the AB Sync operation has begun. This method is
* called only once, at the beginning of a sync transaction
*
*/
void OnStartOperation(in PRInt32 aTransactionID, in PRUint32 aMsgSize);
/**
* Notify the observer that progress as occurred for the AB Sync operation
*/
void OnProgress(in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax);
/**
* Notify the observer with a status message for sync operation
*/
void OnStatus(in PRInt32 aTransactionID, in wstring aMsg);
/**
* Notify the observer that the AB Sync operation has been sent. This
* method is called once when the networking library has finished processing
* the sync operation.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aProtocolResponse - The protocol response sent by the AB server
*/
void OnStopOperation(in PRInt32 aTransactionID, in nsresult aStatus,
in wstring aMsg, in string aProtocolResponse);
};

View File

@ -1 +0,0 @@
absync.properties

View File

@ -1,40 +0,0 @@
# 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):
#
#
# The following are used by the Mailing list dialog
#
syncDoneSuccess=Synchronization completed.
syncDoneFailed=Synchronization Failed.
syncDoneCancelled=Synchronization cancelled by user.
syncProgress=Synchronization received %d bytes...
syncStarting=Synchronization starting with %d byte request...
syncConnect=Synchronization connecting to server...
syncStartingAuth=Synchronization authentication started...
syncAuthSuccess=Synchronization authentication complete.
syncAuthFailed=Synchronization authentication failed.
syncInvalidResponse=The server returned invalid response!
syncServerError=The server returned the error: %s
syncNeedPrefs=You need to fill in your Address Book Synchronization preferences before attempting a synchronization operation.
passwordPrompt=Enter your Netscape.com User Name and Password for Address Book Synchronization
passwordTitle=Enter Password
passwordError=You must enter a valid screen name and password for Address Book Synchronization
syncInProgress=Address Book Synchronization in progress...please wait...
exceedMaxRecordError=Synchronization failed because your Personal Address Book has exceeded the maximum limit of 1500 entries. Remove some entries from your Personal Address Book, and then try again.

View File

@ -1,77 +0,0 @@
#
# 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):
#
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = absyncsvc
XPIDL_MODULE = absync
LIBRARY_NAME = absync_s
META_COMPONENT = mail
REQUIRES = xpcom \
string \
necko \
mime \
docshell \
uriloader \
pref \
widget \
msgbase \
msgbaseutil \
dom \
rdf \
addrbook \
intl \
mork \
mimetype \
windowwatcher \
unicharutil \
$(NULL)
CPPSRCS = \
nsAbSyncPostEngine.cpp \
nsAbSync.cpp \
nsAbSyncCRCModel.cpp \
nsABSyncDriver.cpp \
nsSyncDecoderRing.cpp \
$(NULL)
EXPORTS = \
nsAbSyncPostEngine.h \
nsAbSync.h \
nsAbSyncCRCModel.h \
nsABSyncDriver.h \
nsSyncDecoderRing.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.
FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
ifeq ($(OS_ARCH), Linux)
DEFINES += -D_BSD_SOURCE
endif

View File

@ -1,283 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsABSyncDriver.h"
#include "nsIAbSync.h"
#include "nsAbSyncCID.h"
#include "nsIServiceManager.h"
#include "nsTextFormatter.h"
#include "nsIStringBundle.h"
#include "prmem.h"
#include "nsString.h"
#include "nsCRT.h"
NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbSyncDriver, nsIAbSyncDriver)
//NS_IMPL_ISUPPORTS1(nsAbSyncDriver, nsIAbSyncDriver)
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
nsAbSyncDriver::nsAbSyncDriver()
{
/* member initializers and constructor code */
mTransactionID = -1;
mStatus = nsnull;
}
nsAbSyncDriver::~nsAbSyncDriver()
{
/* destructor code */
}
/**
* Notify the observer that the AB Sync Authorization operation has begun.
*
*/
NS_IMETHODIMP
nsAbSyncDriver::OnStartAuthOperation(void)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
// Tweak the button...
mStatus->StartMeteors();
mStatus->ShowProgress(0);
outValue = GetString(NS_LITERAL_STRING("syncStartingAuth").get());
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/**
* Notify the observer that the AB Sync operation has been completed.
*
* This method is called regardless of whether the the operation was
* successful.
*
* aTransactionID - the ID for this particular request
* aStatus - Status code for the sync request
* aMsg - A text string describing the error (if any).
* aCookie - hmmm...cooookies!
*/
NS_IMETHODIMP
nsAbSyncDriver::OnStopAuthOperation(nsresult aStatus, const PRUnichar *aMsg, const char *aCookie)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
if (NS_SUCCEEDED(aStatus))
outValue = GetString(NS_LITERAL_STRING("syncAuthSuccess").get());
else
outValue = GetString(NS_LITERAL_STRING("syncAuthFailed").get());
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/* void OnStartOperation (in PRInt32 aTransactionID, in PRUint32 aMsgSize); */
NS_IMETHODIMP nsAbSyncDriver::OnStartOperation(PRInt32 aTransactionID, PRUint32 aMsgSize)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
PRUnichar *msgValue = nsnull;
// Tweak the button...
mStatus->StartMeteors();
mStatus->ShowProgress(50);
outValue = GetString(NS_LITERAL_STRING("syncStarting").get());
msgValue = nsTextFormatter::smprintf(outValue, aMsgSize);
mStatus->ShowStatusString(msgValue);
PR_FREEIF(outValue);
PR_FREEIF(msgValue);
}
return NS_OK;
}
/* void OnProgress (in PRInt32 aTransactionID, in PRUint32 aProgress, in PRUint32 aProgressMax); */
NS_IMETHODIMP nsAbSyncDriver::OnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
PRUnichar *msgValue = nsnull;
outValue = GetString(NS_LITERAL_STRING("syncProgress").get());
msgValue = nsTextFormatter::smprintf(outValue, aProgress);
mStatus->ShowStatusString(msgValue);
PR_FREEIF(outValue);
PR_FREEIF(msgValue);
}
return NS_OK;
}
/* void OnStatus (in PRInt32 aTransactionID, in wstring aMsg); */
NS_IMETHODIMP nsAbSyncDriver::OnStatus(PRInt32 aTransactionID, const PRUnichar *aMsg)
{
return mStatus->ShowStatusString(aMsg);
}
/* void OnStopOperation (in PRInt32 aTransactionID, in nsresult aStatus, in wstring aMsg); */
NS_IMETHODIMP nsAbSyncDriver::OnStopOperation(PRInt32 aTransactionID, nsresult aStatus, const PRUnichar *aMsg)
{
if (mStatus)
{
PRUnichar *outValue = nsnull;
// Tweak the button...
mStatus->StopMeteors();
mStatus->CloseWindow();
if (NS_SUCCEEDED(aStatus))
outValue = GetString(NS_LITERAL_STRING("syncDoneSuccess").get());
else
{
if (mCancelled)
outValue = GetString(NS_LITERAL_STRING("syncDoneCancelled").get());
else
outValue = GetString(NS_LITERAL_STRING("syncDoneFailed").get());
}
mStatus->ShowStatusString(outValue);
PR_FREEIF(outValue);
}
return NS_OK;
}
/* void KickIt (); */
NS_IMETHODIMP nsAbSyncDriver::KickIt(nsIMsgStatusFeedback *aStatus, nsIDOMWindowInternal *aDocShell)
{
nsresult rv = NS_OK;
PRInt32 stateVar;
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_FAILED(rv) || !sync)
return rv;
mCancelled = PR_FALSE;
sync->GetCurrentState(&stateVar);
if (stateVar != nsIAbSyncState::nsIAbSyncIdle)
return NS_ERROR_FAILURE;
mStatus = aStatus;
// Add ourselves to the party!
sync->AddSyncListener((nsIAbSyncListener *)this);
rv = sync->PerformAbSync(aDocShell, &mTransactionID);
if (NS_SUCCEEDED(rv))
{
if (mStatus)
{
PRUnichar *msgValue = nsnull;
msgValue = GetString(NS_LITERAL_STRING("syncStartingAuth").get());
mStatus->ShowStatusString(msgValue);
PR_FREEIF(msgValue);
}
}
else
{
// We failed, turn the button back on...
mStatus->StopMeteors();
mStatus->CloseWindow();
}
return rv;
}
#define AB_STRING_URL "chrome://messenger/locale/addressbook/absync.properties"
PRUnichar *
nsAbSyncDriver::GetString(const PRUnichar *aStringName)
{
nsresult res = NS_OK;
PRUnichar *ptrv = nsnull;
if (!mStringBundle)
{
static const char propertyURL[] = AB_STRING_URL;
nsCOMPtr<nsIStringBundleService> sBundleService =
do_GetService(NS_STRINGBUNDLE_CONTRACTID, &res);
if (NS_SUCCEEDED(res) && (nsnull != sBundleService))
{
res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(mStringBundle));
}
}
if (mStringBundle)
res = mStringBundle->GetStringFromName(aStringName, &ptrv);
if ( NS_SUCCEEDED(res) && (ptrv) )
return ptrv;
else
return nsCRT::strdup(aStringName);
}
//
// What if we want to stop the operation? Call this!
//
NS_IMETHODIMP nsAbSyncDriver::CancelIt()
{
nsresult rv = NS_OK;
PRInt32 stateVar;
mCancelled = PR_TRUE;
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_FAILED(rv) || !sync)
return rv;
sync->GetCurrentState(&stateVar);
if (stateVar == nsIAbSyncState::nsIAbSyncIdle)
return NS_ERROR_FAILURE;
// Cancel this mess...
return sync->CancelAbSync();
}

View File

@ -1,66 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsAbSyncDriver_h__
#define __nsAbSyncDriver_h__
#include "nsIAbSyncDriver.h"
#include "nsIMsgStatusFeedback.h"
#include "nsIStringBundle.h"
#include "nsCOMPtr.h"
class nsAbSyncDriver : public nsIAbSyncDriver
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNCDRIVER
NS_DECL_NSIABSYNCLISTENER
nsAbSyncDriver();
virtual ~nsAbSyncDriver();
/* additional members */
PRUnichar *GetString(const PRUnichar *aStringName);
private:
nsCOMPtr<nsIStringBundle> mStringBundle;
PRInt32 mTransactionID;
nsCOMPtr<nsIMsgStatusFeedback> mStatus;
PRBool mCancelled;
};
#endif /* __nsAbSyncDriver_h__ */

File diff suppressed because it is too large Load Diff

View File

@ -1,294 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsIAbSync_h__
#define __nsIAbSync_h__
#include "nsIAbSync.h"
#include "nsIAbSyncPostListener.h"
#include "nsIAbSyncPostEngine.h"
#include "nsCOMPtr.h"
#include "nsIAddrDatabase.h"
#include "nsIAbDirectory.h"
#include "nsIAbMDBCard.h"
#include "nsAbSyncCRCModel.h"
#include "nsVoidArray.h"
#include "nsIStringBundle.h"
#include "nsIDocShell.h"
#include "nsIFileSpec.h"
//
// Basic Sync Logic
// Keep a Sync mapping table like:
//
// ServerRecordID - Unique ID for a record provided by the
// UAB server.
// LocalRecordID - Local Unique ID, for mobile devices this
// is assigned by the mobile device.
// CRC - CRC of the record last time we synced.
// Flags - Operation to apply to this record. ADD
// if it's new, MOD if it's been modified,
// RET if it was already sent to the server
// but an error occured, etc.
//
// Step 1:
// When the user begins a sync, run through the local database and update the
// sync mapping table. If the CRC has changed, mark the entry modified, if
// it's a new record, add an entry and mark it new, if a record was deleted,
// mark the entry deleted, etc.
//
// Sync approach - server handles all conflict resolution:
//
// Step 2:
// Using the sync mapping table and the local records database, generate the change
// list to send to the server. Mark any modified or new record with the RET (retry)
// flag.
//
// Step 3:
// Get the response back from the server. Since the communication was successful,
// clear the RET (retry) flag on all records. Then apply the server changes back
// to the local database (updating the CRC's in the process). Save the changes to
// the local database, clear the sync mapping table flags and save the new sync
// mapping table.
//
typedef struct {
PRInt32 serverID;
PRInt32 localID;
ulong CRC;
PRUint32 flags;
} syncMappingRecord;
#define SYNC_MODIFIED 0x0001 // Must modify record on server
#define SYNC_ADD 0x0002 // Must add record to server
#define SYNC_DELETED 0x0004 // Must delete record from server
#define SYNC_RETRY 0x0008 // Sent to server but failed...must retry!
#define SYNC_RENUMBER 0x0010 // Renumber on the server
#define SYNC_PROCESSED 0x8000 // We processed the entry...nothing to do
#define SYNC_ALLTAGS 1000
#define SYNC_EMAILS 2000
#define ABSYNC_PROTOCOL "2.2.1.1.2.1.2.2.1.1.1.2"
#define ABSYNC_VERSION "Demo"
#define ABSYNC_HOME_PHONE_TYPE "Home"
#define ABSYNC_WORK_PHONE_TYPE "Work"
#define ABSYNC_FAX_PHONE_TYPE "Fax"
#define ABSYNC_PAGER_PHONE_TYPE "Pager"
#define ABSYNC_CELL_PHONE_TYPE "Cellular"
#define ABSYNC_HOME_PHONE_ID 1
#define ABSYNC_WORK_PHONE_ID 2
#define ABSYNC_FAX_PHONE_ID 3
#define ABSYNC_PAGER_PHONE_ID 4
#define ABSYNC_CELL_PHONE_ID 5
#define SYNC_ESCAPE_ADDUSER "op%3Dadd"
#define SYNC_ESCAPE_MOD "op%3Dmod"
#define SYNC_ESCAPE_DEL "op%3Ddel"
//mailing list
#define SYNC_ESCAPE_MAIL_ADD "op%3DmaillistCreate"
#define SYNC_ESCAPE_MAIL_MOD "op%3DmaillistRen"
#define SYNC_ESCAPE_MAIL_DEL "op%3DmaillistDel"
#define SYNC_ESCAPE_MAIL_EMAIL_MOD "op%3DemailstringUpdate"
#define SYNC_ESCAPE_MAIL_CONTACT_ADD "op%3DmaillistAdd"
#define SYNC_ESCAPE_MAIL_CONTACT_DEL "op%3DmaillistMemberDel"
// group
#define SYNC_ESCAPE_GROUP_DEL "op%3DgrpDel"
// Defines for what type of add this may be?
#define SYNC_SINGLE_USER_TYPE 1
#define SYNC_MAILLIST_TYPE 2
#define SYNC_GROUP_TYPE 3
#define SYNC_UNKNOWN_TYPE 0
// Server errors that need to be converted to more user-friendly ones.
#define SYNC_ERROR_EXCEED_MAX_RECORD "exceed max record"
// Generic name tag for AIM screen name
#define SYNC_PREF_PREFIX_CLIENT_MAP "mail.absync.client_map."
#define SYNC_PREF_PREFIX_SERVER_MAP "mail.absync.server_map."
//
// We need this structure for mapping our field names to the server
// field names
//
#define kMaxColumns 38
typedef struct {
const char *abField;
nsString serverField;
} schemaStruct;
class nsAbSync : public nsIAbSync, public nsIAbSyncPostListener
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNC
NS_DECL_NSIABSYNCPOSTLISTENER
nsAbSync();
virtual ~nsAbSync();
/* additional members */
private:
// Handy methods for listeners...
nsresult DeleteListeners();
nsresult NotifyListenersOnStartSync(PRInt32 aTransactionID, const PRUint32 aMsgSize);
nsresult NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax);
nsresult NotifyListenersOnStatus(PRInt32 aTransactionID, const PRUnichar *aMsg);
nsresult NotifyListenersOnStopSync(PRInt32 aTransactionID, nsresult aStatus, const PRUnichar *aMsg);
nsresult NotifyListenersOnStartAuthOperation(void);
nsresult NotifyListenersOnStopAuthOperation(nsresult aStatus, const PRUnichar *aMsg, const char *aCookie);
nsresult AnalyzeTheLocalAddressBook();
nsresult ProcessServerResponse(const char *aProtocolResponse);
NS_IMETHOD InitSchemaColumns();
NS_IMETHOD OpenAB(char *aAbName, nsIAddrDatabase **aDatabase);
NS_IMETHOD AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *directory);
NS_IMETHOD GenerateProtocolForCard(nsIAbCard *aCard, PRBool aAddId, nsString &protLine);
PRBool ThisCardHasChanged(nsIAbCard *aCard, syncMappingRecord *syncRecord, nsString &protLine);
void InternalInit();
nsresult InternalCleanup(nsresult aResult);
nsresult CleanServerTable(nsVoidArray *aArray);
PRUnichar *GetString(const PRUnichar *aStringName);
nsresult DisplayErrorMessage(const PRUnichar * msg);
nsresult SetDOMWindow(nsIDOMWindowInternal *aWindow);
nsCOMPtr<nsIAbSyncPostEngine> mPostEngine;
nsString mPostString;
nsIAbSyncListener **mListenerArray;
PRInt32 mListenerArrayCount;
PRInt32 mCurrentState;
PRInt32 mLastChangeNum;
char *mUserName;
nsCOMPtr<nsIStringBundle> mStringBundle;
// Setting for ABSync operations...
char *mAbSyncServer;
PRInt32 mAbSyncPort;
char *mAbSyncAddressBook;
char *mAbSyncAddressBookFileName;
PRInt32 mTransactionID;
PRInt32 mCurrentPostRecord;
nsCOMPtr<nsIFileSpec> mHistoryFile;
nsCOMPtr<nsIFileSpec> mLockFile;
PRBool mLastSyncFailed;
PRUint32 mOldTableSize;
syncMappingRecord *mOldSyncMapingTable; // Old history table...
PRUint32 mNewTableSize;
syncMappingRecord *mNewSyncMapingTable; // New table after reading address book
nsVoidArray *mNewServerTable; // New entries from the server
PRUint32 mCrashTableSize;
syncMappingRecord *mCrashTable; // Comparison table for crash recovery...
char *mProtocolResponse; // what the server said...
char *mProtocolOffset; // where in the buffer are we?
schemaStruct mSchemaMappingList[kMaxColumns];
///////////////////////////////////////////////
// The following is for protocol parsing
///////////////////////////////////////////////
PRBool EndOfStream(); // If this returns true, we are done with the data...
PRBool ParseNextSection(); // Deal with next section
nsresult AdvanceToNextLine();
nsresult AdvanceToNextSection();
char *ExtractCurrentLine();
nsresult ExtractInteger(char *aLine, char *aTag, char aDelim, PRInt32 *aRetVal);
char *ExtractCharacterString(char *aLine, char *aTag, char aDelim);
nsresult PatchHistoryTableWithNewID(PRInt32 clientID, PRInt32 serverID, PRInt32 aMultiplier, ulong crc);
nsresult DeleteRecord();
nsresult DeleteList();
nsresult DeleteGroup();
nsresult DeleteCardByServerID(PRInt32 aServerID);
nsresult LocateClientIDFromServerID(PRInt32 aServerID, PRInt32 *aClientID);
PRInt32 DetermineTagType(nsStringArray *aArray);
nsresult AddNewUsers();
nsresult AddValueToNewCard(nsIAbCard *aCard, nsString *aTagName, nsString *aTagValue);
PRBool TagHit(const char *aTag, PRBool advanceToNextLine); // See if we are sitting on a particular tag...and advance if asked
PRBool ErrorFromServer(char **errString); // Return true if the server returned an error...
nsresult ProcessOpReturn();
nsresult ProcessNewRecords();
nsresult ProcessDeletedRecords();
nsresult ProcessLastChange();
nsresult ProcessPhoneNumbersTheyAreSpecial(nsIAbCard *aCard);
PRInt32 GetTypeOfPhoneNumber(const nsAString& tagName);
nsresult AddValueToProtocolLine(const PRUnichar *value, nsString &protocolLine);
// For updating...
PRInt32 HuntForExistingABEntryInServerRecord(PRInt32 aPersonIndex,
nsIAddrDatabase *aDatabase,
nsIAbDirectory *directory,
PRInt32 *aServerID,
nsIAbCard **newCard);
nsresult FindCardByClientID(PRInt32 aClientID,
nsIAddrDatabase *aDatabase,
nsIAbDirectory *directory,
nsIAbCard **aReturnCard);
PRBool CardAlreadyInAddressBook(nsIAbCard *newCard,
PRInt32 *aClientID,
ulong *aRetCRC);
nsString mLocale; // Charset of returned data!
nsStringArray *mDeletedRecordTags; // The deleted record tags from the server...
nsStringArray *mDeletedRecordValues; // The deleted record values from the server...
nsStringArray *mNewRecordTags; // The new record tags from the server...
nsStringArray *mNewRecordValues; // The new record values from the server...
// Only support one column/value pair for now until #128567 is fixed to allow multiple pairs to be set.
nsCString mCurrentGenericColumn; // New generic column from server.
nsString mCurrentGenericValue; // New generic value from server.
nsStringArray *mPhoneTypes; // Phone number types...
nsStringArray *mPhoneValues; // Phone number values...
nsIDocShell *mRootDocShell; // For use in prompts
};
#endif /* __nsIAbSync_h__ */

View File

@ -1,137 +0,0 @@
/******************************************************************************/
/* Start of crcmodel.c */
/******************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the implementation (.c) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/******************************************************************************/
/* */
/* Implementation Notes */
/* -------------------- */
/* To avoid inconsistencies, the specification of each function is not echoed */
/* here. See the header file for a description of these functions. */
/* This package is light on checking because I want to keep it short and */
/* simple and portable (i.e. it would be too messy to distribute my entire */
/* C culture (e.g. assertions package) with this package. */
/* */
/******************************************************************************/
#include "nsAbSyncCRCModel.h"
/******************************************************************************/
/* The following definitions make the code more readable. */
#define BITMASK(X) (1L << (X))
#define MASK32 0xFFFFFFFFL
#define LOCAL static
/******************************************************************************/
LOCAL ulong reflect P_((ulong v,int b));
LOCAL ulong reflect (ulong v, int b)
/* Returns the value v with the bottom b [0,32] bits reflected. */
/* Example: reflect(0x3e23L,3) == 0x3e26 */
{
int i;
ulong t = v;
for (i=0; i<b; i++)
{
if (t & 1L)
v|= BITMASK((b-1)-i);
else
v&= ~BITMASK((b-1)-i);
t>>=1;
}
return v;
}
/******************************************************************************/
LOCAL ulong widmask P_((p_cm_t));
LOCAL ulong widmask (p_cm_t p_cm)
/* Returns a longword whose value is (2^p_cm->cm_width)-1. */
/* The trick is to do this portably (e.g. without doing <<32). */
{
return (((1L<<(p_cm->cm_width-1))-1L)<<1)|1L;
}
/******************************************************************************/
void cm_ini (p_cm_t p_cm)
{
p_cm->cm_reg = p_cm->cm_init;
}
/******************************************************************************/
void cm_nxt (p_cm_t p_cm, int ch)
{
int i;
ulong uch = (ulong) ch;
ulong topbit = BITMASK(p_cm->cm_width-1);
if (p_cm->cm_refin) uch = reflect(uch,8);
p_cm->cm_reg ^= (uch << (p_cm->cm_width-8));
for (i=0; i<8; i++)
{
if (p_cm->cm_reg & topbit)
p_cm->cm_reg = (p_cm->cm_reg << 1) ^ p_cm->cm_poly;
else
p_cm->cm_reg <<= 1;
p_cm->cm_reg &= widmask(p_cm);
}
}
/******************************************************************************/
void cm_blk (p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len)
{
while (blk_len--) cm_nxt(p_cm,*blk_adr++);
}
/******************************************************************************/
ulong cm_crc (p_cm_t p_cm)
{
if (p_cm->cm_refot)
return p_cm->cm_xorot ^ reflect(p_cm->cm_reg,p_cm->cm_width);
else
return p_cm->cm_xorot ^ p_cm->cm_reg;
}
/******************************************************************************/
ulong cm_tab (p_cm_t p_cm,int index)
{
int i;
ulong r;
ulong topbit = BITMASK(p_cm->cm_width-1);
ulong inbyte = (ulong) index;
if (p_cm->cm_refin) inbyte = reflect(inbyte,8);
r = inbyte << (p_cm->cm_width-8);
for (i=0; i<8; i++)
if (r & topbit)
r = (r << 1) ^ p_cm->cm_poly;
else
r<<=1;
if (p_cm->cm_refin) r = reflect(r,p_cm->cm_width);
return r & widmask(p_cm);
}
/******************************************************************************/
/* End of crcmodel.c */
/******************************************************************************/

View File

@ -1,149 +0,0 @@
/******************************************************************************/
/* Start of crcmodel.h */
/******************************************************************************/
/* */
/* Author : Ross Williams (ross@guest.adelaide.edu.au.). */
/* Date : 3 June 1993. */
/* Status : Public domain. */
/* */
/* Description : This is the header (.h) file for the reference */
/* implementation of the Rocksoft^tm Model CRC Algorithm. For more */
/* information on the Rocksoft^tm Model CRC Algorithm, see the document */
/* titled "A Painless Guide to CRC Error Detection Algorithms" by Ross */
/* Williams (ross@guest.adelaide.edu.au.). This document is likely to be in */
/* "ftp.adelaide.edu.au/pub/rocksoft". */
/* */
/* Note: Rocksoft is a trademark of Rocksoft Pty Ltd, Adelaide, Australia. */
/* */
/******************************************************************************/
/* */
/* How to Use This Package */
/* ----------------------- */
/* Step 1: Declare a variable of type cm_t. Declare another variable */
/* (p_cm say) of type p_cm_t and initialize it to point to the first */
/* variable (e.g. p_cm_t p_cm = &cm_t). */
/* */
/* Step 2: Assign values to the parameter fields of the structure. */
/* If you don't know what to assign, see the document cited earlier. */
/* For example: */
/* p_cm->cm_width = 16; */
/* p_cm->cm_poly = 0x8005L; */
/* p_cm->cm_init = 0L; */
/* p_cm->cm_refin = TRUE; */
/* p_cm->cm_refot = TRUE; */
/* p_cm->cm_xorot = 0L; */
/* Note: Poly is specified without its top bit (18005 becomes 8005). */
/* Note: Width is one bit less than the raw poly width. */
/* */
/* Step 3: Initialize the instance with a call cm_ini(p_cm); */
/* */
/* Step 4: Process zero or more message bytes by placing zero or more */
/* successive calls to cm_nxt. Example: cm_nxt(p_cm,ch); */
/* */
/* Step 5: Extract the CRC value at any time by calling crc = cm_crc(p_cm); */
/* If the CRC is a 16-bit value, it will be in the bottom 16 bits. */
/* */
/******************************************************************************/
/* */
/* Design Notes */
/* ------------ */
/* PORTABILITY: This package has been coded very conservatively so that */
/* it will run on as many machines as possible. For example, all external */
/* identifiers have been restricted to 6 characters and all internal ones to */
/* 8 characters. The prefix cm (for Crc Model) is used as an attempt to avoid */
/* namespace collisions. This package is endian independent. */
/* */
/* EFFICIENCY: This package (and its interface) is not designed for */
/* speed. The purpose of this package is to act as a well-defined reference */
/* model for the specification of CRC algorithms. If you want speed, cook up */
/* a specific table-driven implementation as described in the document cited */
/* above. This package is designed for validation only; if you have found or */
/* implemented a CRC algorithm and wish to describe it as a set of parameters */
/* to the Rocksoft^tm Model CRC Algorithm, your CRC algorithm implementation */
/* should behave identically to this package under those parameters. */
/* */
/******************************************************************************/
/* The following #ifndef encloses this entire */
/* header file, rendering it indempotent. */
#ifndef CM_DONE
#define CM_DONE
#include "prtypes.h"
/******************************************************************************/
/* The following definitions are extracted from my style header file which */
/* would be cumbersome to distribute with this package. The DONE_STYLE is the */
/* idempotence symbol used in my style header file. */
typedef unsigned long ulong;
typedef unsigned char * p_ubyte_;
/* Change to the second definition if you don't have prototypes. */
#define P_(A) A
/* #define P_(A) () */
/* Uncomment this definition if you don't have void. */
/* typedef int void; */
/******************************************************************************/
/* CRC Model Abstract Type */
/* ----------------------- */
/* The following type stores the context of an executing instance of the */
/* model algorithm. Most of the fields are model parameters which must be */
/* set before the first initializing call to cm_ini. */
typedef struct
{
int cm_width; /* Parameter: Width in bits [8,32]. */
ulong cm_poly; /* Parameter: The algorithm's polynomial. */
ulong cm_init; /* Parameter: Initial register value. */
PRBool cm_refin; /* Parameter: Reflect input bytes? */
PRBool cm_refot; /* Parameter: Reflect output CRC? */
ulong cm_xorot; /* Parameter: XOR this to output CRC. */
ulong cm_reg; /* Context: Context during execution. */
} cm_t;
typedef cm_t *p_cm_t;
/******************************************************************************/
/* Functions That Implement The Model */
/* ---------------------------------- */
/* The following functions animate the cm_t abstraction. */
void cm_ini P_((p_cm_t p_cm));
/* Initializes the argument CRC model instance. */
/* All parameter fields must be set before calling this. */
void cm_nxt P_((p_cm_t p_cm,int ch));
/* Processes a single message byte [0,255]. */
void cm_blk P_((p_cm_t p_cm,p_ubyte_ blk_adr,ulong blk_len));
/* Processes a block of message bytes. */
ulong cm_crc P_((p_cm_t p_cm));
/* Returns the CRC value for the message bytes processed so far. */
/******************************************************************************/
/* Functions For Table Calculation */
/* ------------------------------- */
/* The following function can be used to calculate a CRC lookup table. */
/* It can also be used at run-time to create or check static tables. */
ulong cm_tab P_((p_cm_t p_cm,int index));
/* Returns the i'th entry for the lookup table for the specified algorithm. */
/* The function examines the fields cm_width, cm_poly, cm_refin, and the */
/* argument table index in the range [0,255] and returns the table entry in */
/* the bottom cm_width bytes of the return value. */
/******************************************************************************/
/* End of the header file idempotence #ifndef */
#endif
/******************************************************************************/
/* End of crcmodel.h */
/******************************************************************************/

View File

@ -1,859 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "msgCore.h" // for pre-compiled headers
#include "nsCOMPtr.h"
#include <stdio.h>
#include "nscore.h"
#include "prprf.h"
#include "nsEscape.h"
#include "nsIFactory.h"
#include "nsISupports.h"
#include "comi18n.h"
#include "prmem.h"
#include "plstr.h"
#include "nsIPref.h"
#include "nsIComponentManager.h"
#include "nsIURI.h"
#include "nsString.h"
#include "nsReadableUtils.h"
#include "nsAbSyncPostEngine.h"
#include "nsIIOService.h"
#include "nsIChannel.h"
#include "nsNetUtil.h"
#include "nsMimeTypes.h"
#include "nsIHttpChannel.h"
#include "nsIUploadChannel.h"
#include "nsTextFormatter.h"
#include "nsICookieService.h"
#include "nsIAbSync.h"
#include "nsAbSyncCID.h"
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
static NS_DEFINE_CID(kPrefCID, NS_PREF_CID);
static NS_DEFINE_CID(kCookieServiceCID, NS_COOKIESERVICE_CID);
static NS_DEFINE_CID(kCAbSyncMojoCID, NS_AB_SYNC_MOJO_CID);
static NS_DEFINE_CID(kAbSync, NS_ABSYNC_SERVICE_CID);
/*
* This function will be used by the factory to generate an
* object class object....
*/
NS_METHOD
nsAbSyncPostEngine::Create(nsISupports *aOuter, REFNSIID aIID, void **aResult)
{
if (aOuter)
return NS_ERROR_NO_AGGREGATION;
nsAbSyncPostEngine *ph = new nsAbSyncPostEngine();
if (ph == nsnull)
return NS_ERROR_OUT_OF_MEMORY;
return ph->QueryInterface(aIID, aResult);
}
NS_IMPL_ADDREF(nsAbSyncPostEngine)
NS_IMPL_RELEASE(nsAbSyncPostEngine)
NS_INTERFACE_MAP_BEGIN(nsAbSyncPostEngine)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsIStreamListener)
NS_INTERFACE_MAP_ENTRY(nsIRequestObserver)
NS_INTERFACE_MAP_ENTRY(nsIInterfaceRequestor)
NS_INTERFACE_MAP_ENTRY(nsIURIContentListener)
NS_INTERFACE_MAP_ENTRY(nsIAbSyncPostEngine)
NS_INTERFACE_MAP_END
/*
* Inherited methods for nsMimeConverter
*/
nsAbSyncPostEngine::nsAbSyncPostEngine()
{
// Init member variables...
mTotalWritten = 0;
mStillRunning = PR_TRUE;
mListenerArray = nsnull;
mListenerArrayCount = 0;
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
mTransactionID = 0;
mMessageSize = 0;
mAuthenticationRunning = PR_TRUE;
mCookie = nsnull;
mUser = nsnull;
mSyncProtocolRequest = nsnull;
mSyncProtocolRequestPrefix = nsnull;
mChannel = nsnull;
mMojoSyncSpec = nsnull;
}
nsAbSyncPostEngine::~nsAbSyncPostEngine()
{
mStillRunning = PR_FALSE;
PR_FREEIF(mSyncProtocolRequest);
PR_FREEIF(mSyncProtocolRequestPrefix);
PR_FREEIF(mCookie);
PR_FREEIF(mUser);
PR_FREEIF(mMojoSyncSpec);
DeleteListeners();
}
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
PRUint32& decoded_len);
/* ==================================================================
* Base64Encode
*
* Returns number of bytes that were encoded.
*
* >0 -> OK
* -1 -> BAD (output buffer not big enough).
*
* ==================================================================
*/
PRInt32 Base64Encode(const unsigned char *in_str, PRInt32 in_len, char *out_str,
PRInt32 out_len)
{
static unsigned char base64[] =
{
/* 0 1 2 3 4 5 6 7 */
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', /* 0 */
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', /* 1 */
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', /* 2 */
'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', /* 3 */
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 4 */
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', /* 5 */
'w', 'x', 'y', 'z', '0', '1', '2', '3', /* 6 */
'4', '5', '6', '7', '8', '9', '+', '/' /* 7 */
};
PRInt32 curr_out_len = 0;
PRInt32 i = 0;
unsigned char a, b, c;
out_str[0] = '\0';
if (in_len > 0)
{
while (i < in_len)
{
a = in_str[i];
b = (i + 1 >= in_len) ? 0 : in_str[i + 1];
c = (i + 2 >= in_len) ? 0 : in_str[i + 2];
if (i + 2 < in_len)
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
+ ((c >> 6) & 0x3)]);
out_str[curr_out_len++] = (base64[c & 0x3F]);
}
else if (i + 1 < in_len)
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = (base64[((b << 2) & 0x3c)
+ ((c >> 6) & 0x3)]);
out_str[curr_out_len++] = '=';
}
else
{
out_str[curr_out_len++] = (base64[(a >> 2) & 0x3F]);
out_str[curr_out_len++] = (base64[((a << 4) & 0x30)
+ ((b >> 4) & 0xf)]);
out_str[curr_out_len++] = '=';
out_str[curr_out_len++] = '=';
}
i += 3;
if((curr_out_len + 4) > out_len)
{
return(-1);
}
}
out_str[curr_out_len] = '\0';
}
return curr_out_len;
}
/*
* This routine decodes base64 string to a buffer.
* Populates 'out_str' with b64 decoded data.
*
* Returns number of bytes that were decoded.
* >0 -> OK
* -1 -> BAD (output buffer not big enough).
*/
PRInt32 Base64Decode(const char *in_str, unsigned char *out_str,
PRUint32* decoded_len)
{
return Base64Decode_int(in_str, out_str, *decoded_len);
}
PRInt32 Base64Decode_int(const char *in_str, unsigned char *out_str,
PRUint32& decoded_len)
{
PRInt32 in_len = strlen (/*(char *)*/ in_str);
PRInt32 ii = 0;
PRInt32 a = 0;
char ch;
PRInt32 b1 = 0;
long b4 = 0;
PRInt32 nn = 0;
/* Decode remainder of base 64 string */
while (ii < in_len)
{
ch = in_str[ii++];
if (ch >= 'A' && ch <= 'Z') b1 = (ch - 'A');
else if (ch >= 'a' && ch <= 'z') b1 = 26 + (ch - 'a');
else if (ch >= '0' && ch <= '9') b1 = 52 + (ch - '0');
else if (ch == '+') b1 = 62;
else if (ch == '/') b1 = 63;
else if (ch == '\r' || ch == '\n') continue;
else
{
if (ch == '=')
{
if (nn == 3)
{
if ((a + 2) > (PRInt32) decoded_len)
return (-1); /* Bail. Buffer overflow */
b4 = (b4 << 6);
out_str[a++] = (char) (0xff & (b4 >> 16));
out_str[a++] = (char) (0xff & (b4 >> 8));
}
else if (nn == 2)
{
if ((a + 1) > (PRInt32) decoded_len)
{
return (-1); /* Bail. Buffer overflow */
}
b4 = (b4 << 12);
out_str[a++] = (char) (0xff & (b4 >> 16));
}
}
break;
}
b4 = (b4 << 6) | (long) b1;
nn++;
if (nn == 4)
{
if ((a + 3) > (PRInt32) decoded_len)
{
return (-1); /* Bail. Buffer overflow */
}
out_str[a++] = (char) (0xff & (b4 >> 16));
out_str[a++] = (char) (0xff & (b4 >> 8));
out_str[a++] = (char) (0xff & (b4));
nn = 0;
}
}
out_str[a] = '\0';
decoded_len = a;
return (a);
}
NS_IMETHODIMP nsAbSyncPostEngine::GetInterface(const nsIID & aIID, void * *aInstancePtr)
{
NS_ENSURE_ARG_POINTER(aInstancePtr);
return QueryInterface(aIID, aInstancePtr);
}
// nsIURIContentListener support
NS_IMETHODIMP
nsAbSyncPostEngine::OnStartURIOpen(nsIURI* aURI, PRBool* aAbortOpen)
{
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::IsPreferred(const char * aContentType,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
return CanHandleContent(aContentType, PR_TRUE, aDesiredContentType,
aCanHandleContent);
}
NS_IMETHODIMP
nsAbSyncPostEngine::CanHandleContent(const char * aContentType,
PRBool aIsContentPreferred,
char ** aDesiredContentType,
PRBool * aCanHandleContent)
{
if (nsCRT::strcasecmp(aContentType, MESSAGE_RFC822) == 0)
*aDesiredContentType = nsCRT::strdup("text/html");
// since we explicilty loaded the url, we always want to handle it!
*aCanHandleContent = PR_TRUE;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::DoContent(const char * aContentType,
PRBool aIsContentPreferred,
nsIRequest *request,
nsIStreamListener ** aContentHandler,
PRBool * aAbortProcess)
{
nsresult rv = NS_OK;
if (aAbortProcess)
*aAbortProcess = PR_FALSE;
QueryInterface(NS_GET_IID(nsIStreamListener), (void **) aContentHandler);
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetParentContentListener(nsIURIContentListener** aParent)
{
*aParent = nsnull;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::SetParentContentListener(nsIURIContentListener* aParent)
{
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetLoadCookie(nsISupports ** aLoadCookie)
{
*aLoadCookie = mLoadCookie;
NS_IF_ADDREF(*aLoadCookie);
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::SetLoadCookie(nsISupports * aLoadCookie)
{
mLoadCookie = aLoadCookie;
return NS_OK;
}
nsresult
nsAbSyncPostEngine::StillRunning(PRBool *running)
{
*running = mStillRunning;
return NS_OK;
}
// Methods for nsIStreamListener...
nsresult
nsAbSyncPostEngine::OnDataAvailable(nsIRequest *request, nsISupports * ctxt, nsIInputStream *aIStream,
PRUint32 sourceOffset, PRUint32 aLength)
{
PRUint32 readLen = aLength;
char *buf = (char *)PR_Malloc(aLength);
if (!buf)
return NS_ERROR_OUT_OF_MEMORY; /* we couldn't allocate the object */
// read the data from the input stram...
nsresult rv = aIStream->Read(buf, aLength, &readLen);
if (NS_FAILED(rv)) return rv;
// write to the protocol response buffer...
mProtocolResponse.Append(NS_ConvertASCIItoUCS2(buf, readLen));
PR_FREEIF(buf);
mTotalWritten += readLen;
if (!mAuthenticationRunning)
NotifyListenersOnProgress(mTransactionID, mTotalWritten, 0);
return NS_OK;
}
// Methods for nsIRequestObserver
nsresult
nsAbSyncPostEngine::OnStartRequest(nsIRequest *request, nsISupports *ctxt)
{
if (mAuthenticationRunning)
NotifyListenersOnStartAuthOperation();
else
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, nsresult aStatus)
{
#ifdef NS_DEBUG_rhp
printf("nsAbSyncPostEngine::OnStopRequest()\n");
#endif
char *tProtResponse = nsnull;
//
// Now complete the stream!
//
mStillRunning = PR_FALSE;
// Check the content type!
nsCOMPtr<nsIChannel> channel = do_QueryInterface(request);
if (channel)
{
nsCAutoString contentType;
nsCAutoString charset;
if (NS_SUCCEEDED(channel->GetContentType(contentType)) &&
!contentType.Equals(NS_LITERAL_CSTRING(UNKNOWN_CONTENT_TYPE)))
{
mContentType = contentType;
}
if (NS_SUCCEEDED(channel->GetContentCharset(charset)) && !charset.IsEmpty())
{
mCharset = charset;
}
}
// set the state...
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostIdle;
if (mAuthenticationRunning)
{
nsresult rv;
if (mSyncMojo)
rv = mSyncMojo->GetAbSyncMojoResults(&mUser, &mCookie, &mMojoSyncSpec, &mMojoSyncPort);
if (NS_SUCCEEDED(rv))
{
// Before we really get started...lets let sync know who is doing this...
nsCOMPtr<nsIAbSync> sync(do_GetService(kAbSync, &rv));
if (NS_SUCCEEDED(rv) || sync)
sync->SetAbSyncUser(mUser);
// Base64 encode then url encode it...
//
char tUser[256] = "";
if (Base64Encode((unsigned char *)mUser, strlen(mUser), tUser, sizeof(tUser)) < 0)
{
rv = NS_ERROR_FAILURE;
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
else
{
char *tUser2 = nsEscape(tUser, url_Path);
if (!tUser2)
{
rv = NS_ERROR_FAILURE;
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
else
{
mSyncProtocolRequestPrefix = PR_smprintf("cn=%s&cc=%s&", tUser2, mCookie);
PR_FREEIF(tUser2);
NotifyListenersOnStopAuthOperation(aStatus, tProtResponse);
KickTheSyncOperation();
}
}
// RICHIE - Special here to show the server we are hitting!
// RICHIE - REMOVE THIS BEFORE SHIPPING!!!!
#ifdef DEBUG
PRUnichar *msgValue = nsnull;
msgValue = nsTextFormatter::smprintf(nsString(NS_LITERAL_STRING("Server: %s - port %d")).get(),
mMojoSyncSpec, mMojoSyncPort);
NotifyListenersOnStatus(mTransactionID, msgValue);
PR_FREEIF(msgValue);
// RICHIE
#endif
}
else
{
NotifyListenersOnStopAuthOperation(rv, tProtResponse);
NotifyListenersOnStopSending(mTransactionID, rv, nsnull);
}
mSyncMojo = nsnull;
}
else
{
tProtResponse = ToNewCString(mProtocolResponse);
NotifyListenersOnStopSending(mTransactionID, aStatus, tProtResponse);
}
PR_FREEIF(tProtResponse);
// Time to return...
return NS_OK;
}
/* void AddSyncListener (in nsIAbSyncPostListener aListener); */
NS_IMETHODIMP nsAbSyncPostEngine::AddPostListener(nsIAbSyncPostListener *aListener)
{
if ( (mListenerArrayCount > 0) || mListenerArray )
{
++mListenerArrayCount;
mListenerArray = (nsIAbSyncPostListener **)
PR_Realloc(*mListenerArray, sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
if (!mListenerArray)
return NS_ERROR_OUT_OF_MEMORY;
else
{
mListenerArray[mListenerArrayCount - 1] = aListener;
return NS_OK;
}
}
else
{
mListenerArrayCount = 1;
mListenerArray = (nsIAbSyncPostListener **) PR_Malloc(sizeof(nsIAbSyncPostListener *) * mListenerArrayCount);
if (!mListenerArray)
return NS_ERROR_OUT_OF_MEMORY;
memset(mListenerArray, 0, (sizeof(nsIAbSyncPostListener *) * mListenerArrayCount));
mListenerArray[0] = aListener;
NS_ADDREF(mListenerArray[0]);
return NS_OK;
}
}
/* void RemoveSyncListener (in nsIAbSyncPostListener aListener); */
NS_IMETHODIMP nsAbSyncPostEngine::RemovePostListener(nsIAbSyncPostListener *aListener)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] == aListener)
{
NS_RELEASE(mListenerArray[i]);
mListenerArray[i] = nsnull;
return NS_OK;
}
return NS_ERROR_INVALID_ARG;
}
nsresult
nsAbSyncPostEngine::DeleteListeners()
{
if ( (mListenerArray) && (*mListenerArray) )
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
{
NS_RELEASE(mListenerArray[i]);
}
PR_FREEIF(mListenerArray);
}
mListenerArrayCount = 0;
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStartAuthOperation(void)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStartAuthOperation();
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStopAuthOperation(aStatus, nsnull, aCookie);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStartOperation(aTransactionID, aMsgSize);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnProgress(aTransactionID, aProgress, aProgressMax);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStatus(aTransactionID, aMsg);
return NS_OK;
}
nsresult
nsAbSyncPostEngine::NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
char *aProtocolResponse)
{
PRInt32 i;
for (i=0; i<mListenerArrayCount; i++)
if (mListenerArray[i] != nsnull)
mListenerArray[i]->OnStopOperation(aTransactionID, aStatus, nsnull, aProtocolResponse);
return NS_OK;
}
// Utility to create a nsIURI object...
extern "C" nsresult
nsEngineNewURI(nsIURI** aInstancePtrResult, const char *aSpec, nsIURI *aBase)
{
nsresult res;
if (nsnull == aInstancePtrResult)
return NS_ERROR_NULL_POINTER;
nsCOMPtr<nsIIOService> pService(do_GetService(kIOServiceCID, &res));
if (NS_FAILED(res))
return NS_ERROR_FACTORY_NOT_REGISTERED;
return pService->NewURI(nsDependentCString(aSpec), nsnull, aBase, aInstancePtrResult);
}
nsresult
nsAbSyncPostEngine::FireURLRequest(nsIURI *aURL, const char *postData)
{
nsresult rv;
nsCOMPtr<nsIInputStream> postStream;
if (!postData)
return NS_ERROR_INVALID_ARG;
NS_ENSURE_SUCCESS(NS_NewChannel(getter_AddRefs(mChannel), aURL, nsnull), NS_ERROR_FAILURE);
// Tag the post stream onto the channel...but never seemed to work...so putting it
// directly on the URL spec
//
nsCOMPtr<nsIHttpChannel> httpChannel = do_QueryInterface(mChannel);
if (!httpChannel)
return NS_ERROR_FAILURE;
if (NS_SUCCEEDED(rv = NS_NewPostDataStream(getter_AddRefs(postStream), PR_FALSE, nsDependentCString(postData), 0))){
nsCOMPtr<nsIUploadChannel> uploadChannel(do_QueryInterface(httpChannel));
NS_ASSERTION(uploadChannel, "http must support nsIUploadChannel");
uploadChannel->SetUploadStream(postStream, NS_LITERAL_CSTRING(""), -1);
}
httpChannel->AsyncOpen(this, nsnull);
return NS_OK;
}
/* PRInt32 GetCurrentState (); */
NS_IMETHODIMP nsAbSyncPostEngine::GetCurrentState(PRInt32 *_retval)
{
*_retval = mPostEngineState;
return NS_OK;
}
////////////////////////////////////////////////////////////////////////////////////////
//
// This is the implementation of the actual post driver.
//
////////////////////////////////////////////////////////////////////////////////////////
NS_IMETHODIMP nsAbSyncPostEngine::BuildMojoString(nsIDocShell *aRootDocShell, char **aID)
{
nsresult rv;
if (!aID)
return NS_ERROR_FAILURE;
// Now, get the COMPtr to the Mojo!
if (!mSyncMojo)
{
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
if ( NS_FAILED(rv) || (!mSyncMojo) )
return NS_ERROR_FAILURE;
}
rv = mSyncMojo->BuildMojoString(aRootDocShell, aID);
return rv;
}
NS_IMETHODIMP nsAbSyncPostEngine::SendAbRequest(const char *aSpec, PRInt32 aPort, const char *aProtocolRequest, PRInt32 aTransactionID,
nsIDocShell *aDocShell, const char *aUser)
{
nsresult rv;
// Only try if we are not currently busy!
if (mPostEngineState != nsIAbSyncPostEngineState::nsIAbSyncPostIdle)
return NS_ERROR_FAILURE;
// Now, get the COMPtr to the Mojo!
if (!mSyncMojo)
{
rv = nsComponentManager::CreateInstance(kCAbSyncMojoCID, NULL, NS_GET_IID(nsIAbSyncMojo), getter_AddRefs(mSyncMojo));
if ( NS_FAILED(rv) || (!mSyncMojo) )
return NS_ERROR_FAILURE;
}
if (aUser)
mUser = nsCRT::strdup(aUser);
if (NS_FAILED(mSyncMojo->StartAbSyncMojo(this, aDocShell, mUser)))
return NS_ERROR_FAILURE;
// Set transaction ID and save/init Sync info...
mTransactionID = aTransactionID;
// Init stuff we need....
mSyncProtocolRequest = nsCRT::strdup(aProtocolRequest);
mProtocolResponse.Truncate();
mTotalWritten = 0;
// The first thing we need to do is authentication so do it!
mAuthenticationRunning = PR_TRUE;
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncAuthenticationRunning;
return NS_OK;
}
NS_IMETHODIMP
nsAbSyncPostEngine::KickTheSyncOperation(void)
{
nsresult rv;
nsIURI *workURI = nsnull;
char *protString = nsnull;
// The first thing we need to do is authentication so do it!
mAuthenticationRunning = PR_FALSE;
mProtocolResponse.Truncate();
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
const char postHeader[] = "Content-Type: application/x-www-form-urlencoded\r\nContent-Length: %d\r\nCookie: %s\r\n\r\n%s";
protString = PR_smprintf("%s%s", mSyncProtocolRequestPrefix, mSyncProtocolRequest);
if (protString)
mMessageSize = strlen(protString);
else
mMessageSize = 0;
char *tCommand = PR_smprintf(postHeader, mMessageSize, mCookie, protString);
PR_FREEIF(protString);
#ifdef DEBUG_rhp
printf("COMMAND = %s\n", tCommand);
#endif
if (!tCommand)
{
rv = NS_ERROR_OUT_OF_MEMORY; // we couldn't allocate the string
goto GetOuttaHere;
}
rv = nsEngineNewURI(&workURI, mMojoSyncSpec, nsnull);
if (NS_FAILED(rv) || (!workURI))
{
rv = NS_ERROR_FAILURE; // we couldn't allocate the string
goto GetOuttaHere;
}
if (mMojoSyncPort > 0)
workURI->SetPort(mMojoSyncPort);
rv = FireURLRequest(workURI, tCommand);
if (NS_SUCCEEDED(rv))
NotifyListenersOnStartSending(mTransactionID, mMessageSize);
GetOuttaHere:
NS_IF_RELEASE(workURI);
PR_FREEIF(tCommand);
mPostEngineState = nsIAbSyncPostEngineState::nsIAbSyncPostRunning;
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::CancelAbSync()
{
nsresult rv = NS_ERROR_FAILURE;
if (mSyncMojo)
{
rv = mSyncMojo->CancelTheMojo();
}
else if (mChannel)
{
rv = mChannel->Cancel(NS_BINDING_ABORTED);
}
return rv;
}
NS_IMETHODIMP
nsAbSyncPostEngine::GetMojoUserAndSnack(char **aMojoUser, char **aMojoSnack)
{
if ( (!mUser) || (!mCookie) )
return NS_ERROR_FAILURE;
*aMojoUser = nsCRT::strdup(mUser);
*aMojoSnack = nsCRT::strdup(mCookie);
if ( (!*aMojoUser) || (!*aMojoSnack) )
return NS_ERROR_FAILURE;
else
return NS_OK;
}

View File

@ -1,135 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsAbSyncPostEngine_h_
#define nsAbSyncPostEngine_h_
#include "nsCOMPtr.h"
#include "nsIInputStream.h"
#include "nsIStreamListener.h"
#include "nsFileStream.h"
#include "nsIAbSyncPostEngine.h"
#include "nsIInterfaceRequestor.h"
#include "nsIInterfaceRequestorUtils.h"
#include "nsCURILoader.h"
#include "nsIURIContentListener.h"
#include "nsIURI.h"
#include "nsIAbSyncMojo.h"
#include "nsIChannel.h"
//
// Callback declarations for URL completion
//
// For completion of send/message creation operations...
//
typedef nsresult (*nsPostCompletionCallback ) (nsresult aStatus,
const char *aContentType,
const char *aCharset,
PRInt32 totalSize, const PRUnichar* aMsg,
void *tagData);
class nsAbSyncPostEngine : public nsIAbSyncPostEngine, public nsIStreamListener, public nsIURIContentListener, public nsIInterfaceRequestor {
public:
nsAbSyncPostEngine();
virtual ~nsAbSyncPostEngine();
/* this macro defines QueryInterface, AddRef and Release for this class */
NS_DECL_ISUPPORTS
NS_DECL_NSIABSYNCPOSTENGINE
//
// This is the output stream where the stream converter will write processed data after
// conversion.
//
NS_IMETHOD StillRunning(PRBool *running);
NS_IMETHOD FireURLRequest(nsIURI *aURL, const char *postData);
NS_IMETHOD KickTheSyncOperation();
static NS_METHOD Create(nsISupports *aOuter, REFNSIID aIID, void **aResult);
// Methods for nsIStreamListener
NS_DECL_NSISTREAMLISTENER
// Methods for nsIStreamObserver
NS_DECL_NSIREQUESTOBSERVER
NS_DECL_NSIURICONTENTLISTENER
NS_DECL_NSIINTERFACEREQUESTOR
PRInt32 mPostEngineState;
PRInt32 mTransactionID;
private:
// Handy methods for listeners...
nsresult DeleteListeners();
nsresult NotifyListenersOnStartAuthOperation(void);
nsresult NotifyListenersOnStopAuthOperation(nsresult aStatus, const char *aCookie);
nsresult NotifyListenersOnStartSending(PRInt32 aTransactionID, PRUint32 aMsgSize);
nsresult NotifyListenersOnProgress(PRInt32 aTransactionID, PRUint32 aProgress, PRUint32 aProgressMax);
nsresult NotifyListenersOnStatus(PRInt32 aTransactionID, PRUnichar *aMsg);
nsresult NotifyListenersOnStopSending(PRInt32 aTransactionID, nsresult aStatus,
char *aProtocolResponse);
PRBool mStillRunning; // Are we still running?
PRInt32 mTotalWritten; // Size counter variable
nsString mProtocolResponse; // Protocol response
nsCString mContentType; // The content type retrieved from the server
nsCString mCharset; // The charset retrieved from the server
nsCOMPtr<nsISupports> mLoadCookie; // load cookie used by the uri loader when we post the url
char *mCookie;
char *mUser;
char *mAuthSpec;
PRInt32 mMessageSize; // Size of POST request...
nsIAbSyncPostListener **mListenerArray;
PRInt32 mListenerArrayCount;
// Since we need to do authentication a bit differently, do it here!
PRBool mAuthenticationRunning;
nsCOMPtr<nsIAbSyncMojo> mSyncMojo;
nsCOMPtr<nsIChannel> mChannel;
char *mSyncProtocolRequest;
char *mSyncProtocolRequestPrefix;
char *mMojoSyncSpec;
PRInt32 mMojoSyncPort;
};
#endif /* nsAbSyncPostEngine_h_ */

View File

@ -1,54 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsAbSync.h"
#include "prmem.h"
#include "nsAbSyncCID.h"
#include "nsIPref.h"
#include "nsIServiceManager.h"
#include "nsEscape.h"
#include "nsSyncDecoderRing.h"
nsSyncDecoderRing::nsSyncDecoderRing()
{
}
nsSyncDecoderRing::~nsSyncDecoderRing()
{
}

View File

@ -1,98 +0,0 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
*
* 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 the Initial Developer are Copyright (C) 1998
* 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsSyncDecoderRing_h__
#define __nsSyncDecoderRing_h__
#include "nsIAbSync.h"
#include "nsIAbSyncPostListener.h"
#include "nsIAbSyncPostEngine.h"
#include "nsCOMPtr.h"
#include "nsIAddrDatabase.h"
#include "nsIAbDirectory.h"
#include "nsAbSyncCRCModel.h"
// Server record fields!
#define kServerFirstNameColumn NS_LITERAL_STRING("fname")
#define kServerLastNameColumn NS_LITERAL_STRING("lname")
#define kServerDisplayNameColumn NS_LITERAL_STRING("Display_name")
#define kServerNicknameColumn NS_LITERAL_STRING("nick_name")
#define kServerPriEmailColumn NS_LITERAL_STRING("email1")
#define kServer2ndEmailColumn NS_LITERAL_STRING("email2")
#define kServerPlainTextColumn NS_LITERAL_STRING("Pref_rich_email")
#define kServerWorkPhoneColumn NS_LITERAL_STRING("work_phone")
#define kServerHomePhoneColumn NS_LITERAL_STRING("home_phone")
#define kServerFaxColumn NS_LITERAL_STRING("fax")
#define kServerPagerColumn NS_LITERAL_STRING("pager")
#define kServerCellularColumn NS_LITERAL_STRING("cell_phone")
#define kServerHomeAddressColumn NS_LITERAL_STRING("home_add1")
#define kServerHomeAddress2Column NS_LITERAL_STRING("home_add2")
#define kServerHomeCityColumn NS_LITERAL_STRING("home_city")
#define kServerHomeStateColumn NS_LITERAL_STRING("home_state")
#define kServerHomeZipCodeColumn NS_LITERAL_STRING("home_zip")
#define kServerHomeCountryColumn NS_LITERAL_STRING("home_country")
#define kServerWorkAddressColumn NS_LITERAL_STRING("work_add1")
#define kServerWorkAddress2Column NS_LITERAL_STRING("work_add2")
#define kServerWorkCityColumn NS_LITERAL_STRING("work_city")
#define kServerWorkStateColumn NS_LITERAL_STRING("work_state")
#define kServerWorkZipCodeColumn NS_LITERAL_STRING("work_zip")
#define kServerWorkCountryColumn NS_LITERAL_STRING("work_country")
#define kServerJobTitleColumn NS_LITERAL_STRING("job_title")
#define kServerDepartmentColumn NS_LITERAL_STRING("department")
#define kServerCompanyColumn NS_LITERAL_STRING("company")
#define kServerWebPage1Column NS_LITERAL_STRING("Work_web_page")
#define kServerWebPage2Column NS_LITERAL_STRING("web_page")
#define kServerBirthYearColumn NS_LITERAL_STRING("OMIT:BirthYear")
#define kServerBirthMonthColumn NS_LITERAL_STRING("OMIT:BirthMonth")
#define kServerBirthDayColumn NS_LITERAL_STRING("OMIT:BirthDay")
#define kServerCustom1Column NS_LITERAL_STRING("Custom_1")
#define kServerCustom2Column NS_LITERAL_STRING("Custom_2")
#define kServerCustom3Column NS_LITERAL_STRING("Custom_3")
#define kServerCustom4Column NS_LITERAL_STRING("Custom_4")
#define kServerNotesColumn NS_LITERAL_STRING("addl_info")
#define kServerLastModifiedDateColumn NS_LITERAL_STRING("OMIT:LastModifiedDate")
class nsSyncDecoderRing
{
public:
nsSyncDecoderRing();
virtual ~nsSyncDecoderRing();
};
#endif /* __nsSyncDecoderRing_h__ */

View File

@ -291,7 +291,6 @@ en-US.jar:
locale/en-US/messenger/SmtpServerList.dtd (base/prefs/resources/locale/en-US/SmtpServerList.dtd)
locale/en-US/messenger/smtpEditOverlay.dtd (base/prefs/resources/locale/en-US/smtpEditOverlay.dtd)
locale/en-US/messenger/mailPrefsOverlay.dtd (base/prefs/resources/locale/en-US/mailPrefsOverlay.dtd)
locale/en-US/messenger/addressbook/absync.properties (absync/resources/locale/en-US/absync.properties)
locale/en-US/messenger/addressbook/pref-addressing.dtd (addrbook/prefs/resources/locale/en-US/pref-addressing.dtd)
locale/en-US/messenger/addressbook/pref-directory.dtd (addrbook/prefs/resources/locale/en-US/pref-directory.dtd)
locale/en-US/messenger/addressbook/pref-directory-add.dtd (addrbook/prefs/resources/locale/en-US/pref-directory-add.dtd)

View File

@ -340,8 +340,6 @@ viewer:Components:msgImportText.shlb
viewer:Components:msgImportEudora.shlb
viewer:Components:msgImportComm4xM.shlb
viewer:Components:msgImportComm4xM.xpt
viewer:Components:AbSyncSvc.shlb
viewer:Components:AbSyncSvc.xpt
viewer:Components:nsLDAPPrefsService.js
viewer:Components:msgsmime.shlb
viewer:Components:msgsmime.xpt

View File

@ -379,8 +379,6 @@ bin/components/impText.dll
;bin/components/impComm4xMail.dll
bin/components/imp4Mail.dll
bin/components/impComm4xMail.xpt
bin/components/absyncsv.dll
bin/components/absync.xpt
bin/components/nsLDAPPrefsService.js
bin/chrome/messenger.jar
bin/chrome/icons/default/abcardWindow.ico

View File

@ -251,7 +251,6 @@ bin/components/msgsearch.xpt
bin/components/nsLDAPPrefsService.js
bin/components/txmgr.xpt
bin/components/import.xpt
bin/components/absync.xpt
bin/chrome/messenger.jar
bin/components/msgsmime.xpt
bin/components/smime-service.js

View File

@ -280,7 +280,6 @@ bin\components\msglocal.xpt
bin\components\msgnews.xpt
bin\components\msgsearch.xpt
bin\components\import.xpt
bin\components\absync.xpt
bin\components\nsLDAPPrefsService.js
bin\components\msgsmime.xpt
bin\components\smime-service.js

View File

@ -333,7 +333,6 @@ bin/components/libsmimestb.so
bin/components/libimport.so
bin/components/libimpText.so
bin/components/libimpComm4xMail.so
bin/components/libabsyncsvc.so
bin/components/mailnews.xpt
bin/components/mime.xpt
bin/components/msgbase.xpt
@ -347,7 +346,6 @@ bin/components/nsLDAPPrefsService.js
bin/components/txmgr.xpt
bin/components/import.xpt
bin/components/impComm4xMail.xpt
bin/components/absync.xpt
bin/chrome/messenger.jar
bin/components/libmsgsmime.so
bin/components/msgsmime.xpt

View File

@ -275,8 +275,6 @@ bin\components\impEudra.dll
bin\components\impText.dll
bin\components\impComm4xMail.dll
bin\components\impComm4xMail.xpt
bin\components\absyncsv.dll
bin\components\absync.xpt
bin\components\nsLDAPPrefsService.js
bin\chrome\messenger.jar
bin\chrome\messenger\*