Fix bug 868737 - Allow loading different calendar processing backends. r=mmecca
--HG-- rename : calendar/base/build/Makefile.in => calendar/base/backend/libical/build/Makefile.in rename : calendar/base/build/calBaseModule.cpp => calendar/base/backend/libical/build/calBaseModule.cpp rename : calendar/base/build/moz.build => calendar/base/backend/libical/build/moz.build rename : calendar/base/src/calAttributeHelpers.h => calendar/base/backend/libical/calAttributeHelpers.h rename : calendar/base/src/calDateTime.cpp => calendar/base/backend/libical/calDateTime.cpp rename : calendar/base/src/calDateTime.h => calendar/base/backend/libical/calDateTime.h rename : calendar/base/src/calDuration.cpp => calendar/base/backend/libical/calDuration.cpp rename : calendar/base/src/calDuration.h => calendar/base/backend/libical/calDuration.h rename : calendar/base/src/calICSService.cpp => calendar/base/backend/libical/calICSService.cpp rename : calendar/base/src/calICSService.h => calendar/base/backend/libical/calICSService.h rename : calendar/base/src/calPeriod.cpp => calendar/base/backend/libical/calPeriod.cpp rename : calendar/base/src/calPeriod.h => calendar/base/backend/libical/calPeriod.h rename : calendar/base/src/calRecurrenceRule.cpp => calendar/base/backend/libical/calRecurrenceRule.cpp rename : calendar/base/src/calRecurrenceRule.h => calendar/base/backend/libical/calRecurrenceRule.h rename : calendar/base/src/calTimezone.cpp => calendar/base/backend/libical/calTimezone.cpp rename : calendar/base/src/calTimezone.h => calendar/base/backend/libical/calTimezone.h rename : calendar/base/src/calUtils.cpp => calendar/base/backend/libical/calUtils.cpp rename : calendar/base/src/calUtils.h => calendar/base/backend/libical/calUtils.h
This commit is contained in:
Родитель
5c77c9e25e
Коммит
1d5322ef2b
|
@ -0,0 +1,14 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
EXTRA_COMPONENTS = calBackendLoader.js calBackendLoader.manifest
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -0,0 +1,63 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
function calBackendLoader() {
|
||||
this.wrappedJSObject = this;
|
||||
try {
|
||||
this.loadBackend();
|
||||
} catch (e) {
|
||||
dump("### Error loading backend: " + e + "\n");
|
||||
}
|
||||
}
|
||||
|
||||
const calBackendLoaderClassID = Components.ID("{0314c271-7168-40fa-802e-83c8c46a557e}");
|
||||
const calBackendLoaderInterfaces = [Components.interfaces.nsIObserver];
|
||||
calBackendLoader.prototype = {
|
||||
classID: calBackendLoaderClassID,
|
||||
QueryInterface: XPCOMUtils.generateQI(calBackendLoaderInterfaces),
|
||||
classInfo: XPCOMUtils.generateCI({
|
||||
classID: calBackendLoaderClassID,
|
||||
contractID: "@mozilla.org/calendar/backend-loader;1",
|
||||
classDescription: "Calendar Backend Loader",
|
||||
interaces: calBackendLoaderInterfaces,
|
||||
flags: Components.interfaces.nsIClassInfo.SINGLETON
|
||||
}),
|
||||
|
||||
loaded: false,
|
||||
|
||||
observe: function() {
|
||||
// Nothing to do here, just need the entry so this is instanciated
|
||||
},
|
||||
|
||||
loadBackend: function loadBackend() {
|
||||
if (this.loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
let backend = "libical";
|
||||
if (Services.prefs.prefHasUserValue("calendar.backend")) {
|
||||
backend = Services.prefs.getCharPref("calendar.backend");
|
||||
}
|
||||
let uri = Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Components.interfaces.nsIResProtocolHandler)
|
||||
.getSubstitution("calendar");
|
||||
|
||||
let file = Services.io.getProtocolHandler("file")
|
||||
.QueryInterface(Components.interfaces.nsIFileProtocolHandler)
|
||||
.getFileFromURLSpec(uri.spec);
|
||||
|
||||
file.append("components");
|
||||
file.append(backend + ".manifest");
|
||||
|
||||
Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar)
|
||||
.autoRegister(file);
|
||||
dump("[calBackendLoader] Using " + backend + " backend at " + file.path + "\n");
|
||||
this.loaded = true;
|
||||
}
|
||||
};
|
||||
|
||||
var NSGetFactory = XPCOMUtils.generateNSGetFactory([calBackendLoader]);
|
|
@ -0,0 +1,3 @@
|
|||
component {0314c271-7168-40fa-802e-83c8c46a557e} calBackendLoader.js
|
||||
contract @mozilla.org/calendar/backend-loader;1 {0314c271-7168-40fa-802e-83c8c46a557e}
|
||||
category profile-after-change calendar-backend-loader @mozilla.org/calendar/backend-loader;1
|
|
@ -0,0 +1,28 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DEPTH = @DEPTH@
|
||||
topsrcdir = @top_srcdir@
|
||||
srcdir = @srcdir@
|
||||
VPATH = @srcdir@
|
||||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = calbase_s
|
||||
MODULE_NAME = calBaseModule
|
||||
FORCE_STATIC_LIB = 1
|
||||
GRE_MODULE = 1
|
||||
FORCE_USE_PIC = 1 # Force use of PIC
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
CPPSRCS = calDateTime.cpp \
|
||||
calDuration.cpp \
|
||||
calPeriod.cpp \
|
||||
calICSService.cpp \
|
||||
calTimezone.cpp \
|
||||
calRecurrenceRule.cpp \
|
||||
calUtils.cpp \
|
||||
$(NULL)
|
||||
|
||||
include $(topsrcdir)/config/rules.mk
|
|
@ -18,16 +18,16 @@ MODULE_NAME = calBaseModule
|
|||
FORCE_SHARED_LIB = 1
|
||||
FORCE_USE_PIC = 1 # Force use of PIC
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
NO_COMPONENTS_MANIFEST = 1
|
||||
|
||||
CPPSRCS = calBaseModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
LOCAL_INCLUDES = \
|
||||
-I$(srcdir)/../src
|
||||
-I$(srcdir)/..
|
||||
|
||||
SHARED_LIBRARY_LIBS = \
|
||||
$(DEPTH)/calendar/base/src/$(LIB_PREFIX)calbase_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/calendar/base/backend/libical/$(LIB_PREFIX)calbase_s.$(LIB_SUFFIX) \
|
||||
$(DEPTH)/calendar/libical/src/libical/$(LIB_PREFIX)mozical.$(LIB_SUFFIX) \
|
||||
$(NULL)
|
||||
|
||||
|
@ -56,3 +56,16 @@ include $(topsrcdir)/config/rules.mk
|
|||
|
||||
# Ensure that we don't embed a manifest referencing the CRT
|
||||
EMBED_MANIFEST_AT =
|
||||
|
||||
BACKEND_MANIFESTS = libical.manifest
|
||||
DEFINES += -DSHARED_LIBRARY=$(SHARED_LIBRARY)
|
||||
|
||||
libs:: $(BACKEND_MANIFESTS)
|
||||
$(EXIT_ON_ERROR) \
|
||||
$(NSINSTALL) -D $(FINAL_TARGET)/components; \
|
||||
for i in $^; do \
|
||||
fname=`basename $$i`; \
|
||||
dest=$(FINAL_TARGET)/components/$${fname}; \
|
||||
$(RM) -f $$dest; \
|
||||
$(PYTHON) $(MOZILLA_SRCDIR)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
|
||||
done
|
|
@ -0,0 +1 @@
|
|||
#expand binary-component __SHARED_LIBRARY__
|
|
@ -218,17 +218,6 @@ calDateTime::ToString(nsACString & aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
calDateTime::SetTimeInTimezone(PRTime aTime, calITimezone * aTimezone)
|
||||
{
|
||||
NS_ENSURE_FALSE(mImmutable, NS_ERROR_OBJECT_IS_IMMUTABLE);
|
||||
NS_ENSURE_ARG_POINTER(aTimezone);
|
||||
icaltimetype icalt;
|
||||
PRTimeToIcaltime(aTime, false, cal::getIcalTimezone(aTimezone), &icalt);
|
||||
FromIcalTime(&icalt, aTimezone);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
calDateTime::GetInTimezone(calITimezone * aTimezone, calIDateTime ** aResult)
|
||||
{
|
|
@ -0,0 +1,10 @@
|
|||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
MODULE = calbase
|
||||
|
||||
DIRS = [
|
||||
'build'
|
||||
]
|
|
@ -0,0 +1,8 @@
|
|||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
DIRS = [
|
||||
'libical',
|
||||
]
|
|
@ -9,6 +9,11 @@ var gCalThreadingEnabled;
|
|||
Components.utils.import("resource:///modules/XPCOMUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// Usually the backend loader gets loaded via profile-after-change, but in case
|
||||
// a calendar component hooks in earlier, its very likely it will use calUtils.
|
||||
// Getting the service here will load if its not already loaded
|
||||
Components.classes["@mozilla.org/calendar/backend-loader;1"].getService();
|
||||
|
||||
EXPORTED_SYMBOLS = ["cal"];
|
||||
let cal = {
|
||||
// new code should land here,
|
||||
|
|
|
@ -5,9 +5,9 @@
|
|||
|
||||
DIRS = [
|
||||
'public',
|
||||
'backend',
|
||||
'src',
|
||||
'modules',
|
||||
'build',
|
||||
]
|
||||
|
||||
MODULE = 'calbase'
|
||||
|
|
|
@ -158,13 +158,6 @@ interface calIDateTime : nsISupports
|
|||
*/
|
||||
AUTF8String toString();
|
||||
|
||||
/**
|
||||
* Set the value of this calIDateTime instance
|
||||
* to aTime milliseconds since the epoch in the
|
||||
* given timezone.
|
||||
*/
|
||||
void setTimeInTimezone(in PRTime aTime, in calITimezone aTimezone);
|
||||
|
||||
/**
|
||||
* Return a new calIDateTime instance that's the result of
|
||||
* converting this one into the given timezone. Valid values
|
||||
|
|
|
@ -10,22 +10,6 @@ VPATH = @srcdir@
|
|||
|
||||
include $(DEPTH)/config/autoconf.mk
|
||||
|
||||
LIBRARY_NAME = calbase_s
|
||||
MODULE_NAME = calBaseModule
|
||||
FORCE_STATIC_LIB = 1
|
||||
FORCE_USE_PIC = 1 # Force use of PIC
|
||||
USE_STATIC_LIBS = 1
|
||||
|
||||
|
||||
CPPSRCS = calDateTime.cpp \
|
||||
calDuration.cpp \
|
||||
calPeriod.cpp \
|
||||
calICSService.cpp \
|
||||
calTimezone.cpp \
|
||||
calRecurrenceRule.cpp \
|
||||
calUtils.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXTRA_COMPONENTS = \
|
||||
calItemModule.manifest \
|
||||
calItemModule.js \
|
||||
|
|
|
@ -34,6 +34,8 @@ const scriptLoadOrder = [
|
|||
];
|
||||
|
||||
function getComponents() {
|
||||
Components.classes["@mozilla.org/calendar/backend-loader;1"].getService();
|
||||
|
||||
return [
|
||||
calAlarm,
|
||||
calAlarmService,
|
||||
|
|
|
@ -127,3 +127,6 @@ pref("calendar.view.useSystemColors", false);
|
|||
// Maximum number of iterations allowed when searching for the next matching
|
||||
// occurrence of a repeating item in calFilter
|
||||
pref("calendar.filter.maxiterations", 50);
|
||||
|
||||
// Backend to use, default to libical for now.
|
||||
pref("calendar.backend", "libical");
|
||||
|
|
Загрузка…
Ссылка в новой задаче