mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Merge weave to weave-partial-view w/ conflicts.
This commit is contained in:
commit
5f8f947cfd
341
services/crypto/Makefile
Executable file → Normal file
341
services/crypto/Makefile
Executable file → Normal file
@ -21,7 +21,6 @@
|
||||
#
|
||||
# Contributor(s):
|
||||
# Dan Mills <thunder@mozilla.com> (original author)
|
||||
# Godwin Chan <godwinchan@hotmail.com> (Darwin Universal Binary)
|
||||
#
|
||||
# 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
|
||||
@ -37,346 +36,32 @@
|
||||
#
|
||||
# ***** END LICENSE BLOCK *****
|
||||
|
||||
# OS detection
|
||||
|
||||
xpidl = $(sdkdir)/bin/xpidl
|
||||
link = link
|
||||
|
||||
sys := $(shell uname -s)
|
||||
wince = $(WINCE)
|
||||
|
||||
ifeq ($(wince), 1)
|
||||
os = WINNT
|
||||
cxx = $(sdkdir)/sdk/bin/arm-wince-gcc
|
||||
xpidl = $(sdkdir)/host/bin/host_xpidl
|
||||
link = $(sdkdir)/sdk/bin/arm-wince-link
|
||||
so = dll
|
||||
else
|
||||
ifeq ($(sys), Darwin)
|
||||
os = Darwin
|
||||
compiler = gcc3
|
||||
cxx = c++
|
||||
so = dylib
|
||||
cppflags += -dynamiclib -DDEBUG
|
||||
else
|
||||
ifeq ($(sys), Linux)
|
||||
os = Linux
|
||||
compiler = gcc3
|
||||
cxx = c++
|
||||
so = so
|
||||
cppflags += -shared
|
||||
else
|
||||
ifeq ($(sys), MINGW32_NT-6.1)
|
||||
os = WINNT
|
||||
compiler = msvc
|
||||
cxx = cl
|
||||
so = dll
|
||||
else
|
||||
ifeq ($(sys), MINGW32_NT-5.1)
|
||||
os = WINNT
|
||||
compiler = msvc
|
||||
cxx = cl
|
||||
so = dll
|
||||
else
|
||||
ifeq ($(sys), SunOS)
|
||||
os = SunOS
|
||||
compiler = cc
|
||||
cxx = CC
|
||||
so = so
|
||||
cppflags += -G
|
||||
else
|
||||
$(error Sorry, your os is unknown/unsupported: $(sys))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Arch detection
|
||||
|
||||
machine := $(shell uname -m)
|
||||
|
||||
ifeq ($(machine), arm)
|
||||
arch = arm
|
||||
else
|
||||
ifeq ($(machine), i386)
|
||||
arch = x86
|
||||
else
|
||||
ifeq ($(machine), i586)
|
||||
arch = x86
|
||||
else
|
||||
ifeq ($(machine), i686)
|
||||
arch = x86
|
||||
else
|
||||
ifeq ($(machine), i86pc)
|
||||
arch = x86
|
||||
else
|
||||
ifeq ($(machine), ppc)
|
||||
arch = ppc
|
||||
else
|
||||
ifeq ($(machine), Power Macintosh)
|
||||
arch = ppc
|
||||
else
|
||||
ifeq ($(machine), x86_64)
|
||||
arch = x86_64
|
||||
else
|
||||
$(error: Sorry, your architecture is unknown/unsupported: $(machine))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
# Universal binary so no need for $(arch) for Darwin
|
||||
|
||||
ifeq ($(sys), Darwin)
|
||||
platform = $(os)
|
||||
else
|
||||
platform = $(os)_$(arch)-$(compiler)
|
||||
endif
|
||||
|
||||
###################################################################
|
||||
# Target and objects
|
||||
|
||||
ifeq ($(sys), Darwin)
|
||||
target = WeaveCrypto
|
||||
target_i386 = WeaveCrypto.i386
|
||||
target_ppc = WeaveCrypto.ppc
|
||||
so_target = $(target:=.$(so))
|
||||
so_target_i386 = $(target_i386:=.$(so))
|
||||
so_target_ppc = $(target_ppc:=.$(so))
|
||||
cpp_objects_i386 = $(cpp_sources:.cpp=.oi386)
|
||||
cpp_objects_ppc = $(cpp_sources:.cpp=.oppc)
|
||||
else
|
||||
target = WeaveCrypto
|
||||
so_target = $(target:=.$(so))
|
||||
cpp_objects = $(cpp_sources:.cpp=.o)
|
||||
endif
|
||||
|
||||
# source and path configurations
|
||||
idl = IWeaveCrypto.idl
|
||||
cpp_sources = WeaveCrypto.cpp WeaveCryptoModule.cpp
|
||||
stage_dir=../dist/stage
|
||||
|
||||
sdkdir ?= ${MOZSDKDIR}
|
||||
destdir = ..
|
||||
platformdir = $(destdir)/platform/$(platform)
|
||||
|
||||
# FIXME: we don't actually require this for e.g. clean
|
||||
ifeq ($(sdkdir),)
|
||||
$(warning No 'sdkdir' variable given)
|
||||
$(warning It should point to the location of the Gecko SDK)
|
||||
$(warning For example: "make sdkdir=/foo/bar/baz")
|
||||
$(warning Or set the MOZSDKDIR environment variable to point to it)
|
||||
$(error )
|
||||
$(error)
|
||||
endif
|
||||
|
||||
idl_headers = $(idl:.idl=.h)
|
||||
idl_typelib = $(idl:.idl=.xpt)
|
||||
cpp_objects = $(cpp_sources:.cpp=.o)
|
||||
so_target = $(target:=.$(so))
|
||||
|
||||
headers = -I$(sdkdir)/include \
|
||||
-I$(sdkdir)/include/system_wrappers \
|
||||
-I$(sdkdir)/include/nss \
|
||||
-I$(sdkdir)/include/xpcom \
|
||||
-I$(sdkdir)/include/string \
|
||||
-I$(sdkdir)/include/pipnss \
|
||||
-I$(sdkdir)/include/nspr \
|
||||
-I$(sdkdir)/sdk/include
|
||||
|
||||
# libraries
|
||||
libdirs := $(sdkdir)/lib $(sdkdir)/bin
|
||||
ifeq ($(wince),1)
|
||||
libs := xpcomglue_s xpcom nspr4 \
|
||||
crmf smime3 ssl3 nss3 nssutil3 \
|
||||
plds4 plc4
|
||||
ifdef platform_target
|
||||
platform=$(platform_target)
|
||||
else
|
||||
libs := xpcomglue xpcomglue_s nspr4 \
|
||||
crmf smime3 ssl3 nss3 nssutil3 \
|
||||
plds4 plc4
|
||||
platform=*
|
||||
endif
|
||||
|
||||
ifeq ($(os), Linux)
|
||||
libs := xpcom_core $(libs)
|
||||
endif
|
||||
all: build
|
||||
|
||||
# compiler and Linker Flags
|
||||
.PHONY: build crypto rebuild_all
|
||||
|
||||
ifeq ($(os), Darwin)
|
||||
libdirs := $(patsubst %,-L%,$(libdirs))
|
||||
libs := $(patsubst %,-l%,$(libs))
|
||||
cppflags_i386 += -c -pipe -Os -arch i386 \
|
||||
-fPIC -fno-rtti -fno-exceptions -fno-strict-aliasing \
|
||||
-fno-common -fshort-wchar -fpascal-strings -pthread \
|
||||
-Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth \
|
||||
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align \
|
||||
-Wno-long-long \
|
||||
-include xpcom-config.h $(headers) \
|
||||
-isysroot /Developer/SDKs/MacOSX10.4u.sdk
|
||||
ldflags_i386 += -pthread -pipe -bundle -arch i386 \
|
||||
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk \
|
||||
-Wl,-executable_path,$(sdkdir)/bin \
|
||||
-Wl,-dead_strip \
|
||||
-Wl,-exported_symbol \
|
||||
-Wl,_NSGetModule \
|
||||
$(libdirs) $(libs)
|
||||
cppflags_ppc += -c -pipe -Os -arch ppc \
|
||||
-fPIC -fno-rtti -fno-exceptions -fno-strict-aliasing \
|
||||
-fno-common -fshort-wchar -fpascal-strings -pthread \
|
||||
-Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth \
|
||||
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align \
|
||||
-Wno-long-long \
|
||||
-include xpcom-config.h $(headers) \
|
||||
-isysroot /Developer/SDKs/MacOSX10.4u.sdk \
|
||||
-force_cpusubtype_ALL
|
||||
ldflags_ppc += -pthread -pipe -bundle -arch ppc \
|
||||
-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk \
|
||||
-Wl,-executable_path,$(sdkdir)/bin \
|
||||
-Wl,-dead_strip \
|
||||
-Wl,-exported_symbol \
|
||||
-Wl,_NSGetModule \
|
||||
-force_cpusubtype_ALL \
|
||||
$(libdirs) $(libs)
|
||||
else
|
||||
ifeq ($(os), Linux)
|
||||
libdirs := $(patsubst %,-L%,$(libdirs))
|
||||
libs := $(patsubst %,-l%,$(libs))
|
||||
cppflags += -pipe -Os \
|
||||
-fPIC -fno-rtti -fno-exceptions -fno-strict-aliasing \
|
||||
-fno-common -pthread \
|
||||
-Wall -Wconversion -Wpointer-arith -Woverloaded-virtual -Wsynth \
|
||||
-Wno-ctor-dtor-privacy -Wno-non-virtual-dtor -Wcast-align \
|
||||
-Wno-long-long \
|
||||
-include xpcom-config.h $(headers)
|
||||
ifneq ($(arch), arm)
|
||||
cppflags += -fshort-wchar
|
||||
else
|
||||
endif
|
||||
ldflags += -pthread -pipe -DMOZILLA_STRICT_API \
|
||||
-Wl,-dead_strip \
|
||||
-Wl,-exported_symbol \
|
||||
-Wl,-z,defs -Wl,-h,WeaveCrypto.so \
|
||||
-Wl,-rpath-link,$(sdkdir)/bin \
|
||||
$(sdkdir)/lib/libxpcomglue_s.a \
|
||||
$(libdirs) $(libs)
|
||||
else
|
||||
ifeq ($(os), SunOS)
|
||||
libdirs := $(patsubst %,-L%,$(libdirs))
|
||||
libs := $(patsubst %,-l%,$(libs))
|
||||
cppflags += -xO5 -s -ztext $(headers)
|
||||
ldflags += -DMOZILLA_STRICT_API \
|
||||
$(sdkdir)/lib/libxpcomglue_s.a \
|
||||
$(libdirs) $(libs)
|
||||
else
|
||||
ifneq ($(wince),)
|
||||
libdirs := $(patsubst %,-LIBPATH:%,$(libdirs))
|
||||
libs := $(patsubst %,$(sdkdir)/lib/%.lib,$(libs))
|
||||
cppflags += -c -nologo -O1 -GR- -TP -Zc:wchar_t- -W3 -Gy $(headers) \
|
||||
-DMOZILLA_STRICT_API \
|
||||
-D"_WIN32_WCE=0x502" -D"UNDER_CE" -D"WIN32_PLATFORM_PSPC" \
|
||||
-D"WINCE" -D"ARM" -D"_ARM_" -D"POCKETPC2003_UI_MODEL" -DXP_WIN
|
||||
ldflags += -DLL $(libdirs) $(libs)
|
||||
rcflags := -r $(headers)
|
||||
else
|
||||
ifeq ($(os), WINNT)
|
||||
libdirs := $(patsubst %,-LIBPATH:%,$(libdirs))
|
||||
libs := $(patsubst %,$(sdkdir)/lib/%.lib,$(libs))
|
||||
cppflags += -c -nologo -O1 -GR- -TP -MT -Zc:wchar_t- -W3 -Gy $(headers) \
|
||||
-DNDEBUG -DTRIMMED -D_CRT_SECURE_NO_DEPRECATE=1 \
|
||||
-D_CRT_NONSTDC_NO_DEPRECATE=1 -DWINVER=0x500 -D_WIN32_WINNT=0x500 \
|
||||
-D_WIN32_IE=0x0500 -DX_DISPLAY_MISSING=1 -DMOZILLA_VERSION=\"1.9pre\" \
|
||||
-DMOZILLA_VERSION_U=1.9pre -DHAVE_SNPRINTF=1 -D_WINDOWS=1 -D_WIN32=1 \
|
||||
-DWIN32=1 -DXP_WIN=1 -DXP_WIN32=1 -DHW_THREADS=1 -DSTDC_HEADERS=1 \
|
||||
-DWIN32_LEAN_AND_MEAN=1 -DNO_X11=1 -DHAVE_MMINTRIN_H=1 \
|
||||
-DHAVE_OLEACC_IDL=1 -DHAVE_ATLBASE_H=1 -DHAVE_WPCAPI_H=1 -D_X86_=1 \
|
||||
-DD_INO=d_ino
|
||||
ldflags += -DLL -NOLOGO -SUBSYSTEM:WINDOWS -NXCOMPAT -SAFESEH -IMPLIB:fake.lib \
|
||||
$(libdirs) $(libs) \
|
||||
kernel32.lib user32.lib gdi32.lib winmm.lib wsock32.lib advapi32.lib
|
||||
rcflags := -r $(headers)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
crypto:
|
||||
$(MAKE) -C src install
|
||||
|
||||
######################################################################
|
||||
build:
|
||||
cp -R -v components $(stage_dir)
|
||||
cd platform;mkdir -p ../$(stage_dir)/platform;cp -R -v $(platform) ../$(stage_dir)/platform
|
||||
|
||||
.PHONY: all build install clean subst
|
||||
|
||||
all: build # default target
|
||||
|
||||
build: subst $(so_target) $(idl_typelib)
|
||||
|
||||
install: build
|
||||
mkdir -p $(destdir)/components
|
||||
mkdir -p $(platformdir)/components
|
||||
cp $(idl_typelib) $(destdir)/components
|
||||
cp $(so_target) $(platformdir)/components
|
||||
|
||||
clean:
|
||||
rm -f $(so_target) $(so_target_i386) $(so_target_ppc) \
|
||||
$(cpp_objects) $(cpp_objects_i386) $(cpp_objects_ppc) \
|
||||
$(idl_typelib) $(idl_headers) $(target:=.res) fake.lib fake.exp WeaveCrypto.rc
|
||||
|
||||
subst:
|
||||
$(substitute) WeaveCrypto.rc.in > WeaveCrypto.rc
|
||||
|
||||
# rules to build the c headers and .xpt from idl
|
||||
$(idl_headers): $(idl)
|
||||
$(xpidl) -m header -I$(sdkdir)/idl $(@:.h=.idl)
|
||||
|
||||
$(idl_typelib): $(idl)
|
||||
$(xpidl) -m typelib -I$(sdkdir)/idl $(@:.xpt=.idl)
|
||||
|
||||
# build and link rules
|
||||
ifeq ($(os), Darwin)
|
||||
$(so_target): $(so_target_i386) $(so_target_ppc)
|
||||
lipo -create -output $(so_target) -arch ppc $(so_target_ppc) \
|
||||
-arch i386 $(so_target_i386)
|
||||
chmod +x $(so_target)
|
||||
|
||||
#i386
|
||||
$(cpp_objects_i386): $(cpp_sources)
|
||||
$(cxx) -o $@ $(cppflags_i386) $(@:.oi386=.cpp)
|
||||
|
||||
$(so_target_i386): $(idl_headers) $(cpp_objects_i386)
|
||||
$(cxx) -o $@ $(ldflags_i386) $(cpp_objects_i386)
|
||||
chmod +x $(so_target_i386)
|
||||
|
||||
#ppc
|
||||
$(cpp_objects_ppc): $(cpp_sources)
|
||||
$(cxx) -o $@ $(cppflags_ppc) $(@:.oppc=.cpp)
|
||||
|
||||
$(so_target_ppc): $(idl_headers) $(cpp_objects_ppc)
|
||||
$(cxx) -o $@ $(ldflags_ppc) $(cpp_objects_ppc)
|
||||
chmod +x $(so_target_ppc)
|
||||
else
|
||||
ifeq ($(os), Linux)
|
||||
$(so_target): $(idl_headers)
|
||||
$(cxx) $(cppflags) -o $@ $(cpp_sources) $(ldflags)
|
||||
chmod +x $@
|
||||
else
|
||||
ifeq ($(os), SunOS)
|
||||
$(so_target): $(idl_headers)
|
||||
$(cxx) $(cppflags) -o $@ $(cpp_sources) $(ldflags)
|
||||
chmod +x $@
|
||||
else
|
||||
ifeq ($(os), WINNT)
|
||||
$(target:=.res): $(target:=.rc)
|
||||
rc -Fo$@ $(rcflags) $(target:=.rc)
|
||||
|
||||
$(cpp_objects): $(cpp_sources)
|
||||
$(cxx) -Fo$@ -Fd$(@:.o=.pdb) $(cppflags) $(@:.o=.cpp)
|
||||
|
||||
$(so_target): $(idl_headers) $(cpp_objects) $(target:=.res)
|
||||
$(link) -OUT:$@ -PDB:$(@:.dll=.pdb) $(cpp_objects) $(target:=.res) $(ldflags)
|
||||
chmod +x $@
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
rebuild_all: crypto build
|
||||
|
@ -1,3 +1,5 @@
|
||||
# Status messages (below the arrow in the center)
|
||||
|
||||
status-offline = signed out
|
||||
status-offline-2 = (offline)
|
||||
status-signing-in =
|
||||
@ -7,36 +9,73 @@ status-idle-2 = (idle)
|
||||
status-sync = signed in as %S
|
||||
status-sync-2 = (syncing)
|
||||
|
||||
welcome = Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam id neque lectus. Donec cursus pulvinar nibh at pretium. Vivamus ante tellus, accumsan vel placerat vestibulum, tristique ac augue. 'Cause that's how I roll.
|
||||
# Bubbles
|
||||
|
||||
#prev = « prev
|
||||
#next = next »
|
||||
prev = prev
|
||||
next = next
|
||||
|
||||
signedin-title = Signed In
|
||||
signedin-text = You are currently logged in as %S
|
||||
signedin-signout = sign out
|
||||
signedin-change-password = change password
|
||||
signedin-change-passphrase = change passphrase
|
||||
|
||||
signin-title = Sign Into Weave
|
||||
signin-newacct = new account
|
||||
signin-newacct = new user
|
||||
signin-username = username
|
||||
signin-password = password
|
||||
signin-passphrase = passphrase
|
||||
signin-help = help
|
||||
signin-help-url = https://services.mozilla.com/help/login/
|
||||
signin-next = sign in
|
||||
|
||||
newacct-title = New Weave Account
|
||||
newacct-username = username
|
||||
newacct-password = password
|
||||
newacct-passphrase = passphrase
|
||||
newacct-email = email address
|
||||
newacct-tos-label = I agree to the
|
||||
newacct-tos-label2 =
|
||||
newacct-tos-link = Terms of Service
|
||||
newacct-tos-url = http://labs.mozilla.com/projects/weave/tos/
|
||||
newacct-tos-label = I agree to the %S
|
||||
newacct-tos = Terms of Service
|
||||
captcha-response = Type in the words above
|
||||
user-taken-password = My username won't work
|
||||
|
||||
willsync-title = Account Created!
|
||||
willsync-text = Sync will begin in %S seconds...
|
||||
willsync-config = choose what to sync
|
||||
willsync-1 = Sync will begin in %S seconds...
|
||||
willsync-config = choose what to sync
|
||||
|
||||
setup-title = Sync Settings
|
||||
setup-1 = Check the things you'd like to sync:
|
||||
setup-sync = sync now
|
||||
|
||||
clientinfo-type-desktop = desktop
|
||||
clientinfo-type-laptop = laptop
|
||||
clientinfo-type-mobile = mobile
|
||||
clientinfo-prefs = choose what to sync
|
||||
|
||||
cloudinfo-title = What's In The Cloud?
|
||||
cloudinfo-erase = erase
|
||||
erase-title = Erase Server Data
|
||||
erase-warning = This will delete all data on the Weave server.\n\nAre you sure you want to do this?
|
||||
|
||||
# Help items
|
||||
|
||||
help-forgot-password = I forgot my password
|
||||
forgot-password-1 = Type in your username and we'll send you an email so you can reset it:
|
||||
forgot-password-box = username
|
||||
forgot-password-ok = send email
|
||||
|
||||
help-forgot-passphrase = I forgot my passphrase
|
||||
forgot-passphrase-1 = You can pick a new passphrase, but all your server data will need to be deleted (it cannot be recovered).
|
||||
forgot-passphrase-2 = To go ahead, click the button below:
|
||||
forgot-passphrase-ok = reset passphrase
|
||||
|
||||
help-helpme = I'm stuck! What do I do?
|
||||
help-helpme-1 = If you're stuck, you might want to try the %S or the %S for help.
|
||||
help-helpme-faq = FAQ
|
||||
help-helpme-forum = Weave discussion forum
|
||||
|
||||
help-user-taken = My username won't work
|
||||
help-user-taken-1 = Your username might be taken, try adding numbers or additional words to it.
|
||||
help-user-taken-2 = Additionally, you can't use special symbols or spaces inside usernames.
|
||||
|
||||
help-newacct-pass = Weave won't accept my password or passphrase
|
||||
help-newacct-pass-1 = The password and passphrase must be different from each other.
|
||||
|
||||
help-no-captcha = I can't see the verification image
|
||||
help-no-captcha-1 = Some add-ons can interfere with the verification image. Try disabling NoScript or similar add-ons.
|
||||
|
@ -1,28 +0,0 @@
|
||||
|
||||
fennec.logging-in = Weave is trying to log in...
|
||||
fennec.logged-in = Weave is logged in.
|
||||
fennec.turned-off = Weave is turned off.
|
||||
fennec.login.error = Weave had an error when trying to log in.
|
||||
fennec.login.error.detail = Login error: %S
|
||||
|
||||
fennec.default.client.type = Mobile
|
||||
|
||||
fennec.sync.complete.time = Sync completed at %S, %S
|
||||
fennec.sync.error.detail = Error: %S
|
||||
fennec.sync.error.generic = Weave had an error when trying to sync.
|
||||
fennec.sync.status = Syncing %S...
|
||||
fennec.sync.status.detail = Syncing (%S %S)...
|
||||
|
||||
fennec.turn.weave.off = Turn Weave Off
|
||||
fennec.turn.weave.on = Turn Weave On
|
||||
|
||||
fennec.username.is = You are user: %S
|
||||
fenec.no.username = No username set.
|
||||
|
||||
fennec.need.credentials = Weave needs more info from you to get started.
|
||||
fennec.need.username = You must enter a Weave username.
|
||||
fennec.need.password = You must enter a Weave password.
|
||||
fennec.need.passphrase = You must enter a Weave passphrase.
|
||||
|
||||
fennec.quitting = Cannot sync, Weave is quitting.
|
||||
fennec.no.sync = Cannot sync, Weave is not logged in.
|
@ -1,5 +1,3 @@
|
||||
<!ENTITY dialog.title "Mozilla Weave Sync - Activity Log">
|
||||
<!ENTITY saveAsButton.label "Save As...">
|
||||
<!ENTITY clearButton.label "Clear Logs">
|
||||
<!ENTITY briefLogTab.label "Brief Log">
|
||||
<!ENTITY verboseLogTab.label "Verbose Log">
|
||||
|
@ -1,18 +0,0 @@
|
||||
<!ENTITY oauth.title "3rd Party Authorization">
|
||||
|
||||
<!ENTITY intro.title "3rd Party Authorization Wizard">
|
||||
<!ENTITY intro.msg "A third party has requested access to your Weave data. Before you can authorize the party, we must first authenticate you.">
|
||||
<!ENTITY intro.uid "Username:">
|
||||
<!ENTITY intro.pwd "Password:">
|
||||
<!ENTITY intro.pas "Verify Passphrase:">
|
||||
<!ENTITY intro.loading "Please Wait...">
|
||||
<!ENTITY intro.success "Your account has been verified! Please click Continue to proceed.">
|
||||
<!ENTITY intro.error "Your account could not be verified, please try again!">
|
||||
|
||||
<!ENTITY conf.title "Authorization">
|
||||
<!ENTITY conf.loading "Please wait while we verify the third party's request...">
|
||||
<!ENTITY conf.proceed "By clicking the Continue button, you automatically authorize the third party. If you do not wish to grant access, you may click the Cancel button.">
|
||||
|
||||
<!ENTITY final.title "Granting Access to third party">
|
||||
<!ENTITY final.processing "Please wait while your data is re-encrypted to enable access by the authorized third party...">
|
||||
<!ENTITY final.manual "Please notify the consumer that their request token was successfully authorized!">
|
@ -1,10 +0,0 @@
|
||||
intro.uidmsg = You are logged in as %S
|
||||
conf.conmsg = A third party identifying itself as %S is requesting access to your Weave Data.
|
||||
conf.error = Sorry, but the third party's request was invalid: %S
|
||||
conf.error1 = a request token was not issued.
|
||||
conf.error2 = the third party is unregistered.
|
||||
conf.error3 = the request token has expired.
|
||||
conf.error4 = your account details could not be verified.
|
||||
final.step1 = Unwrapping symmetric key...
|
||||
final.step2 = Adding third party to your keyring...
|
||||
final.step3 = Done!
|
9
services/sync/locales/en-US/pick-sync.dtd
Normal file
9
services/sync/locales/en-US/pick-sync.dtd
Normal file
@ -0,0 +1,9 @@
|
||||
<!ENTITY dialog.title "Sync with Weave">
|
||||
<!ENTITY dialog.accept "Sync">
|
||||
|
||||
<!ENTITY dir.caption "Direction to sync">
|
||||
<!ENTITY myComputer.label "[my computer]">
|
||||
<!ENTITY weaveCloud.label "[weave cloud]">
|
||||
<!ENTITY dir.resetClient.label "Do a fresh, full sync with the server">
|
||||
<!ENTITY dir.wipeClient.label "Erase local data and restart with server data">
|
||||
<!ENTITY dir.wipeRemote.label "Erase remote data and restart with local data">
|
@ -1,15 +1,5 @@
|
||||
dialog.title = Sync with Weave
|
||||
dialog.accept = Sync
|
||||
|
||||
dir.caption = Direction to sync
|
||||
|
||||
dir.resetClient = Do a fresh, full sync with the server
|
||||
dir.wipeClient = Erase local data and restart with server data
|
||||
dir.wipeRemote = Erase remote data and restart with local data
|
||||
|
||||
dir.wipeClient.warning.title = Confirm Erase Local Data
|
||||
dir.wipeClient.warning = This will erase your local data.\n\nAre you sure you want to do this?
|
||||
dir.wipeRemote.warning.title = Confirm Erase Remote Data
|
||||
dir.wipeRemote.warning = This will erase your remote data.\n\nAre you sure you want to do this?
|
||||
|
||||
data.caption = Data to sync
|
||||
|
@ -1,52 +0,0 @@
|
||||
<!ENTITY prefpane.label "Weave">
|
||||
<!ENTITY syncTab.label "Data">
|
||||
<!ENTITY clientsTab.label "Clients">
|
||||
<!ENTITY advancedTab.label "Advanced">
|
||||
|
||||
<!ENTITY backUpCheckbox.label "Back up and securely synchronize my data to a Weave server">
|
||||
<!ENTITY encryptOnServerCheckbox.label "Encrypt locally and only store encrypted data on server">
|
||||
<!ENTITY syncNowButton.label "Sync Now...">
|
||||
<!ENTITY syncItemsList.label "Synchronize these items:">
|
||||
<!ENTITY bookmarksCheckbox.label "Bookmarks">
|
||||
<!ENTITY historyCheckbox.label "Browsing History">
|
||||
<!ENTITY cookiesCheckbox.label "Cookies">
|
||||
<!ENTITY passwordsCheckbox.label "Saved Passwords">
|
||||
<!ENTITY formsCheckbox.label "Saved Form Data">
|
||||
<!ENTITY tabsCheckbox.label "Tabs">
|
||||
<!ENTITY inputCheckbox.label "Input History">
|
||||
<!ENTITY extensionsCheckbox.label "Extensions">
|
||||
<!ENTITY themesCheckbox.label "Themes">
|
||||
<!ENTITY pluginsCheckbox.label "Search Plugins">
|
||||
<!ENTITY microformatsCheckbox.label "Microformats">
|
||||
|
||||
<!ENTITY instanceName.label "Computer name:">
|
||||
<!ENTITY clientList.label "Computers that are synchronizing with this Weave account:">
|
||||
<!ENTITY examples.label "Examples: "Home", "Work"">
|
||||
|
||||
<!ENTITY serverSettingsCaption.label "Server Settings">
|
||||
<!ENTITY serverLocation.label "Server Location:">
|
||||
<!ENTITY encryption.label "Encryption:">
|
||||
<!ENTITY aesAlgorithmItem.label "AES 256-bit Encryption">
|
||||
<!ENTITY teaAlgorithmItem.label "Placeholder Algorithm">
|
||||
<!ENTITY noEncryptionItem.label "No encryption">
|
||||
<!ENTITY defaultServerRequiresEncryption.description "Note: Encryption is required by default in this version.">
|
||||
<!ENTITY resetServerURLButton.label "Reset to Default">
|
||||
|
||||
<!ENTITY debugCaption.label "Debugging Tools">
|
||||
<!ENTITY eraseServerDataButton.label "Erase Server Data...">
|
||||
<!ENTITY eraseServerDataButton.description "Erase all data on the server">
|
||||
|
||||
<!ENTITY openActivityLogButton.label "Open...">
|
||||
<!ENTITY openActivityLogButton.description "Detailed activity log">
|
||||
|
||||
<!ENTITY fennecOpenPrefsCmd.label "Open Weave Preferences">
|
||||
<!ENTITY fennecOpenPrefsButton.label "Details...">
|
||||
<!ENTITY fennecPrefsHeader.title "Sync Data with Weave...">
|
||||
<!ENTITY fennecPrefsHeader.description "Weave Status Goes Here...">
|
||||
<!ENTITY fennecPrefsHeader.status.label "Weave Status: ">
|
||||
<!ENTITY fennecPrefs.notImplemented.label "Not yet implemented">
|
||||
<!ENTITY fennecPrefs.debug.label "Debug only.">
|
||||
<!ENTITY fennecPrefs.turnWeaveOff.label "Turn Weave Off">
|
||||
<!ENTITY fennecPrefs.weaveUserAccount.label "Weave User Account">
|
||||
<!ENTITY fennecPrefs.youAreUser.label "You are user: ">
|
||||
<!ENTITY fennecPrefs.changeUser.label "Change User">
|
@ -1,6 +0,0 @@
|
||||
erase.server.warning.title = Erase Server Data
|
||||
erase.server.warning = This will delete all data on the Weave server.\n\nAre you sure you want to do this?
|
||||
reset.server.warning.title = Reset Server Data
|
||||
reset.server.warning = This will delete all data on the Weave server.\n\nYou must restart this and any other instances of Firefox you may have running on any computer once you do this.\n\nAre you sure you want to do this?
|
||||
reset.client.warning.title = Reset Client Data
|
||||
reset.client.warning = This will permanently delete all of your bookmarks and browsing history.\n\nAre you sure you want to do this?
|
@ -1,6 +0,0 @@
|
||||
<!ENTITY dialog.title "Weave Sharing">
|
||||
<!ENTITY close.button.label "Close">
|
||||
<!ENTITY share.button.label "Share">
|
||||
<!ENTITY description.top "Enter the Weave ID of the user you wish to share your bookmarks with:">
|
||||
<!ENTITY username.label "Weave ID:">
|
||||
<!ENTITY status.waiting "Waiting...">
|
@ -1,4 +0,0 @@
|
||||
status.ok = Weave sharing complete!
|
||||
status.error = Error. Please check the Weave ID and try again.
|
||||
status.working = Working...
|
||||
folder.message = You have chosen to share the bookmark folder "%S".
|
@ -3,12 +3,9 @@ dialog.accept = Hide
|
||||
status.wait = Waiting for Current Sync to Finish
|
||||
status.active = Syncing with Weave
|
||||
status.success = Sync Complete
|
||||
status.error = Sync Failed
|
||||
status.error = Sync Failed (%1$S)
|
||||
status.closing = Closing...
|
||||
|
||||
status.locked = Server Busy
|
||||
status.tryagain = Please try again in a few minutes.
|
||||
|
||||
status.engine.start = Starting Sync
|
||||
status.engine.process-incoming = Processing Incoming Items
|
||||
status.engine.upload-outgoing = Uploading Outgoing Items
|
||||
|
@ -1,9 +1,9 @@
|
||||
<!ENTITY syncMenu.label "Weave">
|
||||
<!ENTITY logInItem.label "Sign In...">
|
||||
<!ENTITY logOutItem.label "Sign Out">
|
||||
<!ENTITY syncNowItem.label "Sync Now...">
|
||||
<!ENTITY syncNowItem.label "Sync Now">
|
||||
<!ENTITY openPrefsItem.label "Preferences...">
|
||||
<!ENTITY openLogItem.label "Activity Log...">
|
||||
<!ENTITY openLogItem.label "Activity Log">
|
||||
<!ENTITY status.offline.label "Offline">
|
||||
|
||||
<!ENTITY syncTabsMenu.label "Tabs From Other Computers">
|
||||
|
@ -1,28 +1,25 @@
|
||||
# %S is the date and time at which the last sync successfully completed
|
||||
lastSync.label = Last Update: %S
|
||||
|
||||
weaveButtonOffline.label = Sign In
|
||||
weaveButtonOnline.label = Weave
|
||||
shareBookmark.menuItem = Share This Folder...
|
||||
unShareBookmark.menuItem = Stop Sharing This Folder
|
||||
#weaveButtonOffline.label = Sign In
|
||||
#weaveButtonOnline.label = Weave
|
||||
#shareBookmark.menuItem = Share This Folder...
|
||||
#unShareBookmark.menuItem = Stop Sharing This Folder
|
||||
|
||||
status.offline = Not Signed In
|
||||
|
||||
# The next two are not normally used, as we now display the username
|
||||
# when the user is logged in. But if for some reason we can't get the username,
|
||||
# we display these.
|
||||
status.idle = Idle
|
||||
status.active = Working...
|
||||
#status.idle = Idle
|
||||
#status.active = Working...
|
||||
|
||||
error.login.title = Error While Signing In
|
||||
error.login.description = Weave encountered an error while signing you in: %1$S. Please try again.
|
||||
error.login.reason.password = Your username/password failed
|
||||
error.login.reason.unknown = Unknown error
|
||||
error.login.reason.passphrase = Invalid passphrase
|
||||
error.login.reason.network = Network error
|
||||
# should decide if we're going to show this
|
||||
error.logout.title = Error While Signing Out
|
||||
error.logout.description = Weave encountered an error while signing you out. It's probably ok, and you don't have to do anything about it (then why are we bugging you with this info?).
|
||||
error.logout.description = Weave encountered an error while signing you out. It's probably ok, and you don't have to do anything about it.
|
||||
error.sync.title = Error While Syncing
|
||||
error.sync.description = Weave encountered an error while syncing. You might want to try syncing manually to make sure you are up-to-date.
|
||||
error.sync.tryAgainButton.label = Sync Now...
|
||||
error.sync.tryAgainButton.label = Sync Now
|
||||
error.sync.tryAgainButton.accesskey = S
|
||||
|
@ -75,7 +75,6 @@ Collection.prototype = {
|
||||
args.push('older=' + this.older);
|
||||
else if (this.newer) {
|
||||
args.push('newer=' + this.newer);
|
||||
args.push('modified=' + this.newer); // tmp hack for older servers
|
||||
}
|
||||
if (this.full)
|
||||
args.push('full=1');
|
||||
@ -128,63 +127,15 @@ Collection.prototype = {
|
||||
// Save this because onProgress is called with this as the ChannelListener
|
||||
let coll = this;
|
||||
|
||||
// Switch to newline separated records for incremental parsing
|
||||
coll.setHeader("Accept", "application/newlines");
|
||||
|
||||
this._onProgress = function() {
|
||||
// Save some work by quitting early when there's no records
|
||||
if (this._data == "[]")
|
||||
return;
|
||||
|
||||
do {
|
||||
// Strip off the the starting "[" or separating "," or trailing "]" if
|
||||
// it wasn't stripped off from a previous progress update
|
||||
let start = this._data[0];
|
||||
if (start == "[" || start == "," || start == "]")
|
||||
this._data = this._data.slice(1);
|
||||
|
||||
// Track various states of # open braces and ignore for strings
|
||||
let json = "";
|
||||
let braces = 1;
|
||||
let ignore = false;
|
||||
let escaped = false;
|
||||
let length = this._data.length;
|
||||
|
||||
// Skip the first character, the "{", and try to find a json record
|
||||
for (let i = 1; i < length; i++) {
|
||||
let char = this._data[i];
|
||||
|
||||
// Opening a string makes us ignore all characters except close "
|
||||
if (char == '"') {
|
||||
if (!ignore)
|
||||
ignore = true;
|
||||
// It's a real close " if it's not escaped
|
||||
else if (!escaped)
|
||||
ignore = false;
|
||||
}
|
||||
|
||||
// Track if an end quote might be escaped when processing strings
|
||||
if (ignore) {
|
||||
escaped = char == "\\" ? !escaped : false;
|
||||
|
||||
// Don't bother checking other characters when ignoring
|
||||
continue;
|
||||
}
|
||||
|
||||
// Increase the brace count on open {
|
||||
if (char == "{")
|
||||
braces++;
|
||||
// Decrement brace count on close }
|
||||
else if (char == "}" && --braces == 0) {
|
||||
// Split the json record from the rest of the data
|
||||
json = this._data.slice(0, i + 1);
|
||||
this._data = this._data.slice(i + 1);
|
||||
|
||||
// Stop processing for now that we found one record
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// No valid record json found?
|
||||
if (json.length == 0)
|
||||
break;
|
||||
let newline;
|
||||
while ((newline = this._data.indexOf("\n")) > 0) {
|
||||
// Split the json record from the rest of the data
|
||||
let json = this._data.slice(0, newline);
|
||||
this._data = this._data.slice(newline + 1);
|
||||
|
||||
// Deserialize a record from json and give it to the callback
|
||||
let record = new coll._recordObj();
|
||||
@ -192,9 +143,7 @@ Collection.prototype = {
|
||||
record.baseURI = coll.uri;
|
||||
record.id = record.data.id;
|
||||
onRecord(record);
|
||||
|
||||
// Keep processing the data until we can't find a json record
|
||||
} while (true);
|
||||
}
|
||||
|
||||
// Aggressively clean up the objects we created above so that the next set
|
||||
// of records have enough memory to decrypt, reconcile, apply, etc.
|
||||
|
@ -126,18 +126,22 @@ RecordManager.prototype = {
|
||||
_init: function RegordMgr__init() {
|
||||
this._log = Log4Moz.repository.getLogger(this._logName);
|
||||
this._records = {};
|
||||
this._aliases = {};
|
||||
},
|
||||
|
||||
import: function RecordMgr_import(url) {
|
||||
this._log.trace("Importing record: " + (url.spec ? url.spec : url));
|
||||
try {
|
||||
this.lastResource = new Resource(url);
|
||||
this.lastResource.get();
|
||||
// Clear out the last response with empty object if GET fails
|
||||
this.response = {};
|
||||
this.response = new Resource(url).get();
|
||||
|
||||
// Don't parse and save the record on failure
|
||||
if (!this.response.success)
|
||||
return null;
|
||||
|
||||
let record = new this._recordType();
|
||||
record.deserialize(this.lastResource.data);
|
||||
record.uri = url; // NOTE: may override id in this.lastResource.data
|
||||
record.deserialize(this.response);
|
||||
record.uri = url;
|
||||
|
||||
return this.set(url, record);
|
||||
}
|
||||
@ -148,17 +152,10 @@ RecordManager.prototype = {
|
||||
},
|
||||
|
||||
get: function RecordMgr_get(url) {
|
||||
// Note: using url object directly as key for this._records cache does not
|
||||
// work because different url objects (even pointing to the same place) are
|
||||
// different objects and therefore not equal. So always use the string, not
|
||||
// the object, as a key.
|
||||
// TODO: use the string as key for this._aliases as well? (Don't know)
|
||||
// Use a url string as the key to the hash
|
||||
let spec = url.spec ? url.spec : url;
|
||||
if (spec in this._records)
|
||||
return this._records[spec];
|
||||
|
||||
if (url in this._aliases)
|
||||
url = this._aliases[url];
|
||||
return this.import(url);
|
||||
},
|
||||
|
||||
@ -168,10 +165,7 @@ RecordManager.prototype = {
|
||||
},
|
||||
|
||||
contains: function RegordMgr_contains(url) {
|
||||
let record = null;
|
||||
if (url in this._aliases)
|
||||
url = this._aliases[url];
|
||||
if (url in this._records)
|
||||
if ((url.spec || url) in this._records)
|
||||
return true;
|
||||
return false;
|
||||
},
|
||||
@ -182,14 +176,5 @@ RecordManager.prototype = {
|
||||
|
||||
del: function RegordMgr_del(url) {
|
||||
delete this._records[url];
|
||||
},
|
||||
getAlias: function RegordMgr_getAlias(alias) {
|
||||
return this._aliases[alias];
|
||||
},
|
||||
setAlias: function RegordMgr_setAlias(url, alias) {
|
||||
this._aliases[alias] = url;
|
||||
},
|
||||
delAlias: function RegordMgr_delAlias(alias) {
|
||||
delete this._aliases[alias];
|
||||
}
|
||||
};
|
||||
|
@ -225,16 +225,18 @@ SyncEngine.prototype = {
|
||||
return null;
|
||||
if (url[url.length-1] != '/')
|
||||
url += '/';
|
||||
url += "0.3/user/";
|
||||
url += "0.5/";
|
||||
return url;
|
||||
},
|
||||
|
||||
get engineURL() {
|
||||
return this.baseURL + ID.get('WeaveID').username + '/' + this.name + '/';
|
||||
return this.baseURL + ID.get('WeaveID').username +
|
||||
'/storage/' + this.name + '/';
|
||||
},
|
||||
|
||||
get cryptoMetaURL() {
|
||||
return this.baseURL + ID.get('WeaveID').username + '/crypto/' + this.name;
|
||||
return this.baseURL + ID.get('WeaveID').username +
|
||||
'/storage/crypto/' + this.name;
|
||||
},
|
||||
|
||||
get lastSync() {
|
||||
@ -270,7 +272,9 @@ SyncEngine.prototype = {
|
||||
meta.generateIV();
|
||||
meta.addUnwrappedKey(pubkey, symkey);
|
||||
let res = new Resource(meta.uri);
|
||||
res.put(meta.serialize());
|
||||
let resp = res.put(meta.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
// Cache the cryto meta that we just put on the server
|
||||
CryptoMetas.set(meta.uri, meta);
|
||||
@ -331,7 +335,9 @@ SyncEngine.prototype = {
|
||||
Sync.sleep(0);
|
||||
});
|
||||
|
||||
newitems.get();
|
||||
let resp = newitems.get();
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
if (this.lastSync < this._lastSyncTmp)
|
||||
this.lastSync = this._lastSyncTmp;
|
||||
@ -393,6 +399,9 @@ SyncEngine.prototype = {
|
||||
// case when syncing for the first time two machines that already have the
|
||||
// same bookmarks. In this case we change the IDs to match.
|
||||
_reconcile: function SyncEngine__reconcile(item) {
|
||||
if (this._log.level <= Log4Moz.Level.Trace)
|
||||
this._log.trace("Incoming: " + item);
|
||||
|
||||
// Step 1: Check for conflicts
|
||||
// If same as local record, do not upload
|
||||
this._log.trace("Reconcile step 1");
|
||||
@ -437,8 +446,6 @@ SyncEngine.prototype = {
|
||||
|
||||
// Apply incoming records
|
||||
_applyIncoming: function SyncEngine__applyIncoming(item) {
|
||||
if (this._log.level <= Log4Moz.Level.Trace)
|
||||
this._log.trace("Incoming: " + item);
|
||||
try {
|
||||
this._tracker.ignoreAll = true;
|
||||
this._store.applyIncoming(item);
|
||||
@ -463,9 +470,15 @@ SyncEngine.prototype = {
|
||||
// Upload what we've got so far in the collection
|
||||
let doUpload = Utils.bind2(this, function(desc) {
|
||||
this._log.info("Uploading " + desc + " of " + outnum + " records");
|
||||
up.post();
|
||||
if (up.data.modified > this.lastSync)
|
||||
this.lastSync = up.data.modified;
|
||||
let resp = up.post();
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
// Record the modified time of the upload
|
||||
let modified = resp.headers["X-Weave-Timestamp"];
|
||||
if (modified > this.lastSync)
|
||||
this.lastSync = modified;
|
||||
|
||||
up.clearRecords();
|
||||
});
|
||||
|
||||
|
@ -94,6 +94,7 @@ BookmarksEngine.prototype = {
|
||||
_storeObj: BookmarksStore,
|
||||
_trackerObj: BookmarksTracker,
|
||||
|
||||
<<<<<<< local
|
||||
_sync: function BookmarksEngine__sync() {
|
||||
Svc.Bookmark.runInBatchMode({
|
||||
runBatched: Utils.bind2(this, SyncEngine.prototype._sync)
|
||||
@ -142,6 +143,9 @@ BookmarksEngine.prototype = {
|
||||
// TODO for bookmarks, check if it exists and find guid
|
||||
// for everything else (folders, separators) look for parent/pred?
|
||||
}
|
||||
=======
|
||||
_sync: Utils.batchSync("Bookmark", SyncEngine)
|
||||
>>>>>>> other
|
||||
};
|
||||
|
||||
function BookmarksStore() {
|
||||
@ -409,9 +413,12 @@ BookmarksStore.prototype = {
|
||||
record._insertPos, "as", record.title].join(" "));
|
||||
break;
|
||||
case "livemark":
|
||||
newId = this._ls.createLivemark(record._parent, record.title,
|
||||
Utils.makeURI(record.siteUri), Utils.makeURI(record.feedUri),
|
||||
record._insertPos);
|
||||
let siteURI = null;
|
||||
if (record.siteUri != null)
|
||||
siteURI = Utils.makeURI(record.siteUri);
|
||||
|
||||
newId = this._ls.createLivemark(record._parent, record.title, siteURI,
|
||||
Utils.makeURI(record.feedUri), record._insertPos);
|
||||
this._log.debug(["created livemark", newId, "under", record._parent, "at",
|
||||
record._insertPos, "as", record.title, record.siteUri, record.feedUri].
|
||||
join(" "));
|
||||
@ -665,7 +672,10 @@ BookmarksStore.prototype = {
|
||||
case this._bms.TYPE_FOLDER:
|
||||
if (this._ls.isLivemark(placeId)) {
|
||||
record = new Livemark();
|
||||
record.siteUri = this._ls.getSiteURI(placeId).spec;
|
||||
|
||||
let siteURI = this._ls.getSiteURI(placeId);
|
||||
if (siteURI != null)
|
||||
record.siteUri = siteURI.spec;
|
||||
record.feedUri = this._ls.getFeedURI(placeId).spec;
|
||||
|
||||
} else {
|
||||
@ -923,6 +933,12 @@ BookmarksTracker.prototype = {
|
||||
if (this._ignore(itemId))
|
||||
return;
|
||||
|
||||
// Make sure to remove items that now have the exclude annotation
|
||||
if (property == "places/excludeFromBackup") {
|
||||
this.removeChangedID(GUIDForId(itemId));
|
||||
return;
|
||||
}
|
||||
|
||||
// ignore annotations except for the ones that we sync
|
||||
let annos = ["bookmarkProperties/description",
|
||||
"bookmarkProperties/loadInSidebar", "bookmarks/staticTitle",
|
||||
|
@ -81,11 +81,7 @@ HistoryEngine.prototype = {
|
||||
_storeObj: HistoryStore,
|
||||
_trackerObj: HistoryTracker,
|
||||
|
||||
_sync: function HistoryEngine__sync() {
|
||||
Svc.History.runInBatchMode({
|
||||
runBatched: Utils.bind2(this, SyncEngine.prototype._sync)
|
||||
}, null);
|
||||
},
|
||||
_sync: Utils.batchSync("History", SyncEngine),
|
||||
|
||||
_syncFinish: function HistEngine__syncFinish(error) {
|
||||
// Only leave 1 week's worth of history on the server
|
||||
|
@ -1,88 +0,0 @@
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Bookmarks Sync.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Mozilla.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2008
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Atul Varma <varmaa@toolness.com>
|
||||
* Dan Mills <thunder@mozilla.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const Cu = Components.utils;
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
|
||||
const EXPORTED_SYMBOLS = ["FaultTolerance"];
|
||||
|
||||
FaultTolerance = {
|
||||
get Service() {
|
||||
if (!this._Service)
|
||||
this._Service = new FTService();
|
||||
return this._Service;
|
||||
}
|
||||
};
|
||||
|
||||
function FTService() {
|
||||
this._log = Log4Moz.repository.getLogger("FaultTolerance");
|
||||
this._log.level = Log4Moz.Level["Debug"];
|
||||
this._appender = new FTAppender(this);
|
||||
Log4Moz.repository.rootLogger.addAppender(this._appender);
|
||||
}
|
||||
FTService.prototype = {
|
||||
get lastException() this._lastException,
|
||||
onMessage: function FTS_onMessage(message) {
|
||||
// FIXME: we get all log messages here, and could use them to keep track of
|
||||
// our current state
|
||||
},
|
||||
|
||||
onException: function FTS_onException(ex) {
|
||||
this._lastException = ex;
|
||||
this._log.debug(Utils.exceptionStr(ex));
|
||||
return true; // continue sync if thrown by a sync engine
|
||||
}
|
||||
};
|
||||
|
||||
function FTFormatter() {}
|
||||
FTFormatter.prototype = {
|
||||
__proto__: new Log4Moz.Formatter(),
|
||||
format: function FTF_format(message) message
|
||||
};
|
||||
|
||||
function FTAppender(ftService) {
|
||||
this._ftService = ftService;
|
||||
this._name = "FTAppender";
|
||||
this._formatter = new FTFormatter();
|
||||
}
|
||||
FTAppender.prototype = {
|
||||
__proto__: new Log4Moz.Appender(),
|
||||
doAppend: function FTA_append(message) {
|
||||
this._ftService.onMessage(message);
|
||||
}
|
||||
};
|
@ -51,12 +51,9 @@ Utils.lazy(this, 'ID', IDManager);
|
||||
// For storing identities we'll use throughout Weave
|
||||
function IDManager() {
|
||||
this._ids = {};
|
||||
this._aliases = {};
|
||||
}
|
||||
IDManager.prototype = {
|
||||
get: function IDMgr_get(name) {
|
||||
if (name in this._aliases)
|
||||
return this._ids[this._aliases[name]];
|
||||
if (name in this._ids)
|
||||
return this._ids[name];
|
||||
return null;
|
||||
@ -67,15 +64,6 @@ IDManager.prototype = {
|
||||
},
|
||||
del: function IDMgr_del(name) {
|
||||
delete this._ids[name];
|
||||
},
|
||||
getAlias: function IDMgr_getAlias(alias) {
|
||||
return this._aliases[alias];
|
||||
},
|
||||
setAlias: function IDMgr_setAlias(name, alias) {
|
||||
this._aliases[alias] = name;
|
||||
},
|
||||
delAlias: function IDMgr_delAlias(alias) {
|
||||
delete this._aliases[alias];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -50,27 +50,6 @@ Cu.import("resource://weave/constants.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/auth.js");
|
||||
|
||||
// = RequestException =
|
||||
//
|
||||
// This function raises an exception through the call
|
||||
// stack for a failed network request.
|
||||
function RequestException(resource, action, request) {
|
||||
this._resource = resource;
|
||||
this._action = action;
|
||||
this._request = request;
|
||||
this.location = Components.stack.caller;
|
||||
}
|
||||
RequestException.prototype = {
|
||||
get resource() { return this._resource; },
|
||||
get action() { return this._action; },
|
||||
get request() { return this._request; },
|
||||
get status() { return this._request.status; },
|
||||
toString: function ReqEx_toString() {
|
||||
return "Could not " + this._action + " resource " + this._resource.spec +
|
||||
" (" + this._request.responseStatus + ")";
|
||||
}
|
||||
};
|
||||
|
||||
// = Resource =
|
||||
//
|
||||
// Represents a remote network resource, identified by a URI.
|
||||
@ -122,8 +101,6 @@ Resource.prototype = {
|
||||
return this._uri;
|
||||
},
|
||||
set uri(value) {
|
||||
this._dirty = true;
|
||||
this._downloaded = false;
|
||||
if (typeof value == 'string')
|
||||
this._uri = Utils.makeURI(value);
|
||||
else
|
||||
@ -145,17 +122,9 @@ Resource.prototype = {
|
||||
_data: null,
|
||||
get data() this._data,
|
||||
set data(value) {
|
||||
this._dirty = true;
|
||||
this._data = value;
|
||||
},
|
||||
|
||||
_lastChannel: null,
|
||||
_downloaded: false,
|
||||
_dirty: false,
|
||||
get lastChannel() this._lastChannel,
|
||||
get downloaded() this._downloaded,
|
||||
get dirty() this._dirty,
|
||||
|
||||
// ** {{{ Resource.filters }}} **
|
||||
//
|
||||
// Filters are used to perform pre and post processing on
|
||||
@ -188,18 +157,15 @@ Resource.prototype = {
|
||||
// to obtain a request channel.
|
||||
//
|
||||
_createRequest: function Res__createRequest() {
|
||||
this._lastChannel = Svc.IO.newChannel(this.spec, null, null).
|
||||
QueryInterface(Ci.nsIRequest);
|
||||
let channel = Svc.IO.newChannel(this.spec, null, null).
|
||||
QueryInterface(Ci.nsIRequest).QueryInterface(Ci.nsIHttpChannel);
|
||||
|
||||
// Always validate the cache:
|
||||
let loadFlags = this._lastChannel.loadFlags;
|
||||
loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
|
||||
this._lastChannel.loadFlags = loadFlags;
|
||||
this._lastChannel = this._lastChannel.QueryInterface(Ci.nsIHttpChannel);
|
||||
channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE;
|
||||
channel.loadFlags |= Ci.nsIRequest.INHIBIT_CACHING;
|
||||
|
||||
// Setup a callback to handle bad HTTPS certificates.
|
||||
this._lastChannel.notificationCallbacks = new badCertListener();
|
||||
channel.notificationCallbacks = new badCertListener();
|
||||
|
||||
// Avoid calling the authorizer more than once
|
||||
let headers = this.headers;
|
||||
@ -208,9 +174,9 @@ Resource.prototype = {
|
||||
this._log.trace("HTTP Header " + key + ": ***** (suppressed)");
|
||||
else
|
||||
this._log.trace("HTTP Header " + key + ": " + headers[key]);
|
||||
this._lastChannel.setRequestHeader(key, headers[key], false);
|
||||
channel.setRequestHeader(key, headers[key], false);
|
||||
}
|
||||
return this._lastChannel;
|
||||
return channel;
|
||||
},
|
||||
|
||||
_onProgress: function Res__onProgress(channel) {},
|
||||
@ -289,31 +255,44 @@ Resource.prototype = {
|
||||
throw error;
|
||||
}
|
||||
|
||||
if (!channel.requestSucceeded) {
|
||||
this._log.debug(action + " request failed (" + channel.responseStatus + ")");
|
||||
if (this._data)
|
||||
this._log.debug("Error response: " + this._data);
|
||||
throw new RequestException(this, action, channel);
|
||||
|
||||
} else {
|
||||
this._log.debug(action + " request successful (" + channel.responseStatus + ")");
|
||||
|
||||
switch (action) {
|
||||
case "DELETE":
|
||||
if (Utils.checkStatus(channel.responseStatus, null, [[200,300],404])){
|
||||
this._dirty = false;
|
||||
this._data = null;
|
||||
// Set some default values in-case there's no response header
|
||||
let headers = {};
|
||||
let status = 0;
|
||||
let success = true;
|
||||
try {
|
||||
// Read out the response headers if available
|
||||
channel.visitResponseHeaders({
|
||||
visitHeader: function visitHeader(header, value) {
|
||||
headers[header] = value;
|
||||
}
|
||||
});
|
||||
status = channel.responseStatus;
|
||||
success = channel.requestSucceeded;
|
||||
|
||||
if (success) {
|
||||
this._log.debug(action + " success: " + status);
|
||||
switch (action) {
|
||||
case "GET":
|
||||
case "POST":
|
||||
if (this._log.level <= Log4Moz.Level.Trace)
|
||||
this._log.trace(action + " Body: " + this._data);
|
||||
this.filterDownload();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case "GET":
|
||||
case "POST":
|
||||
this._log.trace(action + " Body: " + this._data);
|
||||
this.filterDownload();
|
||||
break;
|
||||
}
|
||||
else
|
||||
this._log.debug(action + " fail: " + status + " " + this._data);
|
||||
}
|
||||
// Got a response but no header; must be cached (use default values)
|
||||
catch(ex) {
|
||||
this._log.debug(action + " cached: " + status);
|
||||
}
|
||||
|
||||
return this._data;
|
||||
let ret = new String(this._data);
|
||||
ret.headers = headers;
|
||||
ret.status = status;
|
||||
ret.success = success;
|
||||
return ret;
|
||||
},
|
||||
|
||||
// ** {{{ Resource.get }}} **
|
||||
|
@ -76,7 +76,6 @@ Cu.import("resource://weave/ext/Sync.js");
|
||||
Cu.import("resource://weave/log4moz.js");
|
||||
Cu.import("resource://weave/constants.js");
|
||||
Cu.import("resource://weave/util.js");
|
||||
Cu.import("resource://weave/faultTolerance.js");
|
||||
Cu.import("resource://weave/auth.js");
|
||||
Cu.import("resource://weave/resource.js");
|
||||
Cu.import("resource://weave/base_records/wbo.js");
|
||||
@ -90,7 +89,6 @@ Cu.import("resource://weave/engines/clientData.js");
|
||||
let Weave = {};
|
||||
Cu.import("resource://weave/constants.js", Weave);
|
||||
Cu.import("resource://weave/util.js", Weave);
|
||||
Cu.import("resource://weave/faultTolerance.js", Weave);
|
||||
Cu.import("resource://weave/auth.js", Weave);
|
||||
Cu.import("resource://weave/resource.js", Weave);
|
||||
Cu.import("resource://weave/base_records/keys.js", Weave);
|
||||
@ -202,32 +200,31 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
get baseURL() {
|
||||
let url = Svc.Prefs.get("serverURL");
|
||||
if (!url)
|
||||
throw "No server URL set";
|
||||
if (url[url.length-1] != '/')
|
||||
url += '/';
|
||||
url += "0.3/";
|
||||
return url;
|
||||
return Utils.getURLPref("serverURL");
|
||||
},
|
||||
set baseURL(value) {
|
||||
Svc.Prefs.set("serverURL", value);
|
||||
},
|
||||
|
||||
get miscURL() {
|
||||
return Utils.getURLPref("miscURL");
|
||||
},
|
||||
set miscURL(value) {
|
||||
Svc.Prefs.set("miscURL", value);
|
||||
},
|
||||
|
||||
get clusterURL() {
|
||||
let url = Svc.Prefs.get("clusterURL");
|
||||
if (!url)
|
||||
return null;
|
||||
if (url[url.length-1] != '/')
|
||||
url += '/';
|
||||
url += "0.3/user/";
|
||||
return url;
|
||||
return Utils.getURLPref("clusterURL", null, "0.5/");
|
||||
},
|
||||
set clusterURL(value) {
|
||||
Svc.Prefs.set("clusterURL", value);
|
||||
this._genKeyURLs();
|
||||
},
|
||||
|
||||
get userURL() {
|
||||
return this.clusterURL + this.username;
|
||||
},
|
||||
|
||||
get userPath() { return ID.get('WeaveID').username; },
|
||||
|
||||
get isLoggedIn() { return this._loggedIn; },
|
||||
@ -261,9 +258,9 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
_genKeyURLs: function WeaveSvc__genKeyURLs() {
|
||||
let url = this.clusterURL + this.username;
|
||||
PubKeys.defaultKeyUri = url + "/keys/pubkey";
|
||||
PrivKeys.defaultKeyUri = url + "/keys/privkey";
|
||||
let url = this.userURL;
|
||||
PubKeys.defaultKeyUri = url + "/storage/keys/pubkey";
|
||||
PrivKeys.defaultKeyUri = url + "/storage/keys/privkey";
|
||||
},
|
||||
|
||||
_checkCrypto: function WeaveSvc__checkCrypto() {
|
||||
@ -315,7 +312,6 @@ WeaveSvc.prototype = {
|
||||
Svc.Observer.addObserver(this, "quit-application", true);
|
||||
Svc.Observer.addObserver(this, "weave:service:sync:finish", true);
|
||||
Svc.Observer.addObserver(this, "weave:service:sync:error", true);
|
||||
FaultTolerance.Service; // initialize FT service
|
||||
|
||||
if (!this.enabled)
|
||||
this._log.info("Weave Sync disabled");
|
||||
@ -458,20 +454,18 @@ WeaveSvc.prototype = {
|
||||
findCluster: function WeaveSvc_findCluster(username) {
|
||||
this._log.debug("Finding cluster for user " + username);
|
||||
|
||||
let res = new Resource(this.baseURL + "api/register/chknode/" + username);
|
||||
let res = new Resource(this.baseURL + "1/" + username + "/node/weave");
|
||||
try {
|
||||
res.get();
|
||||
} catch(ex) {}
|
||||
|
||||
try {
|
||||
switch (res.lastChannel.responseStatus) {
|
||||
let node = res.get();
|
||||
switch (node.status) {
|
||||
case 404:
|
||||
this._log.debug("Using serverURL as data cluster (multi-cluster support disabled)");
|
||||
return Svc.Prefs.get("serverURL");
|
||||
return this.baseURL;
|
||||
case 0:
|
||||
case 200:
|
||||
return "https://" + res.data + "/";
|
||||
return node;
|
||||
default:
|
||||
this._log.debug("Unexpected response code trying to find cluster: " + res.lastChannel.responseStatus);
|
||||
this._log.debug("Unexpected response code: " + node.status);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
@ -519,11 +513,7 @@ WeaveSvc.prototype = {
|
||||
if (isLogin)
|
||||
this.clusterURL = url;
|
||||
|
||||
if (url[url.length-1] != '/')
|
||||
url += '/';
|
||||
url += "0.3/user/";
|
||||
|
||||
let res = new Resource(url + username);
|
||||
let res = new Resource(this.userURL + "/info/collections");
|
||||
res.authenticator = {
|
||||
onRequest: function(headers) {
|
||||
headers['Authorization'] = 'Basic ' + btoa(username + ':' + password);
|
||||
@ -533,11 +523,8 @@ WeaveSvc.prototype = {
|
||||
|
||||
// login may fail because of cluster change
|
||||
try {
|
||||
res.get();
|
||||
} catch (e) {}
|
||||
|
||||
try {
|
||||
switch (res.lastChannel.responseStatus) {
|
||||
let test = res.get();
|
||||
switch (test.status) {
|
||||
case 200:
|
||||
if (passphrase && !this.verifyPassphrase(username, password, passphrase)) {
|
||||
this._setSyncFailure(LOGIN_FAILED_INVALID_PASSPHRASE);
|
||||
@ -552,7 +539,7 @@ WeaveSvc.prototype = {
|
||||
this._log.debug("verifyLogin failed: login failed")
|
||||
return false;
|
||||
default:
|
||||
throw "unexpected HTTP response: " + res.lastChannel.responseStatus;
|
||||
throw "unexpected HTTP response: " + test.status;
|
||||
}
|
||||
} catch (e) {
|
||||
// if we get here, we have either a busted channel or a network error
|
||||
@ -595,7 +582,10 @@ WeaveSvc.prototype = {
|
||||
privkey.payload.iv, newphrase);
|
||||
privkey.payload.keyData = newkey;
|
||||
|
||||
new Resource(privkey.uri).put(privkey.serialize());
|
||||
let resp = new Resource(privkey.uri).put(privkey.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
|
||||
this.passphrase = newphrase;
|
||||
|
||||
return true;
|
||||
@ -603,17 +593,10 @@ WeaveSvc.prototype = {
|
||||
|
||||
changePassword: function WeaveSvc_changePassword(newpass)
|
||||
this._catch(this._notify("changepwd", "", function() {
|
||||
function enc(x) encodeURIComponent(x);
|
||||
let message = "uid=" + enc(this.username) + "&password=" +
|
||||
enc(this.password) + "&new=" + enc(newpass);
|
||||
let url = Svc.Prefs.get('tmpServerURL') + '0.3/api/register/chpwd';
|
||||
let url = this.baseURL + '1/' + this.username + "/password";
|
||||
let res = new Weave.Resource(url);
|
||||
res.authenticator = new Weave.NoOpAuthenticator();
|
||||
res.setHeader("Content-Type", "application/x-www-form-urlencoded",
|
||||
"Content-Length", message.length);
|
||||
|
||||
let resp = res.post(message);
|
||||
if (res.lastChannel.responseStatus != 200) {
|
||||
let resp = res.post(newpass);
|
||||
if (resp.status != 200) {
|
||||
this._log.info("Password change failed: " + resp);
|
||||
throw "Could not change password";
|
||||
}
|
||||
@ -740,49 +723,39 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
_errorStr: function WeaveSvc__errorStr(code) {
|
||||
switch (code) {
|
||||
case "0":
|
||||
return "uid-in-use";
|
||||
case "-1":
|
||||
return "invalid-http-method";
|
||||
case "-2":
|
||||
return "uid-missing";
|
||||
case "-3":
|
||||
return "uid-invalid";
|
||||
case "-4":
|
||||
return "mail-invalid";
|
||||
case "-5":
|
||||
return "mail-in-use";
|
||||
case "-6":
|
||||
return "captcha-challenge-missing";
|
||||
case "-7":
|
||||
return "captcha-response-missing";
|
||||
case "-8":
|
||||
return "password-missing";
|
||||
case "-9":
|
||||
return "internal-server-error";
|
||||
case "-10":
|
||||
return "server-quota-exceeded";
|
||||
case "-11":
|
||||
return "missing-new-field";
|
||||
case "-12":
|
||||
return "password-incorrect";
|
||||
switch (code.toString()) {
|
||||
case "1":
|
||||
return "illegal-method";
|
||||
case "2":
|
||||
return "invalid-captcha";
|
||||
case "3":
|
||||
return "invalid-username";
|
||||
case "4":
|
||||
return "cannot-overwrite-resource";
|
||||
case "5":
|
||||
return "userid-mismatch";
|
||||
case "6":
|
||||
return "json-parse-failure";
|
||||
case "7":
|
||||
return "invalid-password";
|
||||
case "8":
|
||||
return "invalid-record";
|
||||
case "9":
|
||||
return "weak-password";
|
||||
default:
|
||||
return "generic-server-error";
|
||||
}
|
||||
},
|
||||
|
||||
checkUsername: function WeaveSvc_checkUsername(username) {
|
||||
let url = Svc.Prefs.get('tmpServerURL') +
|
||||
"0.3/api/register/checkuser/" + username;
|
||||
|
||||
let url = this.baseURL + "1/" + username;
|
||||
let res = new Resource(url);
|
||||
res.authenticator = new NoOpAuthenticator();
|
||||
|
||||
let data = "";
|
||||
try {
|
||||
data = res.get();
|
||||
if (res.lastChannel.responseStatus == 200 && data == "0")
|
||||
if (data.status == 200 && data == "0")
|
||||
return "available";
|
||||
}
|
||||
catch(ex) {}
|
||||
@ -792,43 +765,35 @@ WeaveSvc.prototype = {
|
||||
},
|
||||
|
||||
createAccount: function WeaveSvc_createAccount(username, password, email,
|
||||
captchaChallenge, captchaResponse) {
|
||||
function enc(x) encodeURIComponent(x);
|
||||
let message = "uid=" + enc(username) + "&password=" + enc(password) +
|
||||
"&mail=" + enc(email) + "&recaptcha_challenge_field=" +
|
||||
enc(captchaChallenge) + "&recaptcha_response_field=" + enc(captchaResponse);
|
||||
captchaChallenge, captchaResponse)
|
||||
{
|
||||
let payload = JSON.stringify({
|
||||
"password": password, "email": email,
|
||||
"captcha-challenge": captchaChallenge,
|
||||
"captcha-response": captchaResponse
|
||||
});
|
||||
|
||||
let url = Svc.Prefs.get('tmpServerURL') + '0.3/api/register/new';
|
||||
let url = this.baseURL + '1/' + username;
|
||||
let res = new Resource(url);
|
||||
res.authenticator = new Weave.NoOpAuthenticator();
|
||||
res.setHeader("Content-Type", "application/x-www-form-urlencoded",
|
||||
"Content-Length", message.length);
|
||||
|
||||
let ret = {};
|
||||
let error = "generic-server-error";
|
||||
try {
|
||||
ret.response = res.post(message);
|
||||
ret.status = res.lastChannel.responseStatus;
|
||||
let register = res.put(payload);
|
||||
if (register.success) {
|
||||
this._log.info("Account created: " + register);
|
||||
return;
|
||||
}
|
||||
|
||||
// No exceptions must have meant it was successful
|
||||
this._log.info("Account created: " + ret.response);
|
||||
return ret;
|
||||
// Must have failed, so figure out the reason
|
||||
if (register.status == 400)
|
||||
error = this._errorStr(register);
|
||||
}
|
||||
catch(ex) {
|
||||
this._log.warn("Failed to create account: " + ex);
|
||||
let status = ex.request.responseStatus;
|
||||
switch (status) {
|
||||
case 400:
|
||||
ret.error = this._errorStr(status);
|
||||
break;
|
||||
case 417:
|
||||
ret.error = "captcha-incorrect";
|
||||
break;
|
||||
default:
|
||||
ret.error = "generic-server-error";
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
return error;
|
||||
},
|
||||
|
||||
// stuff we need to to after login, before we can really do
|
||||
@ -837,7 +802,7 @@ WeaveSvc.prototype = {
|
||||
let reset = false;
|
||||
|
||||
this._log.debug("Fetching global metadata record");
|
||||
let meta = Records.import(this.clusterURL + this.username + "/meta/global");
|
||||
let meta = Records.import(this.userURL + "/storage/meta/global");
|
||||
|
||||
let remoteVersion = (meta && meta.payload.storageVersion)?
|
||||
meta.payload.storageVersion : "";
|
||||
@ -849,7 +814,7 @@ WeaveSvc.prototype = {
|
||||
Svc.Version.compare(COMPATIBLE_VERSION, remoteVersion) > 0) {
|
||||
|
||||
// abort the server wipe if the GET status was anything other than 404 or 200
|
||||
let status = Records.lastResource.lastChannel.responseStatus;
|
||||
let status = Records.response.status;
|
||||
if (status != 200 && status != 404) {
|
||||
this._setSyncFailure(METARECORD_DOWNLOAD_FAIL);
|
||||
this._log.warn("Unknown error while downloading metadata record. " +
|
||||
@ -918,14 +883,10 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
|
||||
if (needKeys) {
|
||||
if (PubKeys.lastResource != null && PrivKeys.lastResource != null &&
|
||||
PubKeys.lastResource.lastChannel.responseStatus != 404 &&
|
||||
PrivKeys.lastResource.lastChannel.responseStatus != 404) {
|
||||
if (PubKeys.response.status != 404 && PrivKeys.response.status != 404) {
|
||||
this._log.warn("Couldn't download keys from server, aborting sync");
|
||||
this._log.debug("PubKey HTTP response status: " +
|
||||
PubKeys.lastResource.lastChannel.responseStatus);
|
||||
this._log.debug("PrivKey HTTP response status: " +
|
||||
PrivKeys.lastResource.lastChannel.responseStatus);
|
||||
this._log.debug("PubKey HTTP status: " + PubKeys.response.status);
|
||||
this._log.debug("PrivKey HTTP status: " + PrivKeys.response.status);
|
||||
this._setSyncFailure(KEYS_DOWNLOAD_FAIL);
|
||||
return false;
|
||||
}
|
||||
@ -956,8 +917,6 @@ WeaveSvc.prototype = {
|
||||
} catch (e) {
|
||||
this._setSyncFailure(KEYS_UPLOAD_FAIL);
|
||||
this._log.error("Could not upload keys: " + Utils.exceptionStr(e));
|
||||
// FIXME no lastRequest anymore
|
||||
//this._log.error(keys.pubkey.lastRequest.responseText);
|
||||
}
|
||||
} else {
|
||||
this._setSyncFailure(SETUP_FAILED_NO_PASSPHRASE);
|
||||
@ -1073,7 +1032,8 @@ WeaveSvc.prototype = {
|
||||
// this is sort of pseudocode, need a way to get at the
|
||||
if (!shouldBackoff) {
|
||||
try {
|
||||
shouldBackoff = Utils.checkStatus(Records.lastResource.lastChannel.responseStatus, null, [500,[502,504]]);
|
||||
shouldBackoff = Utils.checkStatus(Records.response.status, null,
|
||||
[500, [502, 504]]);
|
||||
}
|
||||
catch (e) {
|
||||
// if responseStatus throws, we have a network issue in play
|
||||
@ -1226,15 +1186,14 @@ WeaveSvc.prototype = {
|
||||
}
|
||||
catch(e) {
|
||||
// maybe a 401, cluster update needed?
|
||||
if (e.constructor.name == "RequestException" && e.status == 401) {
|
||||
if (this.updateCluster(this.username))
|
||||
return this._syncEngine(engine);
|
||||
}
|
||||
if (e.status == 401 && this.updateCluster(this.username))
|
||||
return this._syncEngine(engine);
|
||||
|
||||
this._syncError = true;
|
||||
this._weaveStatusCode = WEAVE_STATUS_PARTIAL;
|
||||
this._detailedStatus.setEngineStatus(engine.name, e);
|
||||
if (FaultTolerance.Service.onException(e))
|
||||
return true;
|
||||
this._log.debug(Utils.exceptionStr(e));
|
||||
return true;
|
||||
}
|
||||
},
|
||||
|
||||
@ -1248,7 +1207,7 @@ WeaveSvc.prototype = {
|
||||
Sync.sleep(2000);
|
||||
|
||||
this._log.debug("Uploading new metadata record");
|
||||
meta = new WBORecord(this.clusterURL + this.username + "/meta/global");
|
||||
meta = new WBORecord(this.userURL + "/storage/meta/global");
|
||||
meta.payload.syncID = Clients.syncID;
|
||||
this._updateRemoteVersion(meta);
|
||||
},
|
||||
@ -1260,8 +1219,9 @@ WeaveSvc.prototype = {
|
||||
|
||||
this._log.debug("Setting meta payload storage version to " + WEAVE_VERSION);
|
||||
meta.payload.storageVersion = WEAVE_VERSION;
|
||||
let res = new Resource(meta.uri);
|
||||
res.put(meta.serialize());
|
||||
let resp = new Resource(meta.uri).put(meta.serialize());
|
||||
if (!resp.success)
|
||||
throw resp;
|
||||
},
|
||||
|
||||
/**
|
||||
@ -1273,19 +1233,18 @@ WeaveSvc.prototype = {
|
||||
wipeServer: function WeaveSvc_wipeServer(engines)
|
||||
this._catch(this._notify("wipe-server", "", function() {
|
||||
// Grab all the collections for the user
|
||||
let userURL = this.clusterURL + this.username + "/";
|
||||
let res = new Resource(userURL);
|
||||
let res = new Resource(this.userURL + "/info/collections");
|
||||
res.get();
|
||||
|
||||
// Get the array of collections and delete each one
|
||||
let allCollections = JSON.parse(res.data);
|
||||
for each (let name in allCollections) {
|
||||
for (let name in allCollections) {
|
||||
try {
|
||||
// If we have a list of engines, make sure it's one we want
|
||||
if (engines && engines.indexOf(name) == -1)
|
||||
continue;
|
||||
|
||||
new Resource(userURL + name).delete();
|
||||
new Resource(this.userURL + "/storage/" + name).delete();
|
||||
}
|
||||
catch(ex) {
|
||||
this._log.debug("Exception on wipe of '" + name + "': " + Utils.exceptionStr(ex));
|
||||
|
@ -124,6 +124,29 @@ let Utils = {
|
||||
};
|
||||
},
|
||||
|
||||
batchSync: function batchSync(service, engineType) {
|
||||
return function batchedSync() {
|
||||
let engine = this;
|
||||
let batchEx = null;
|
||||
|
||||
// Try running sync in batch mode
|
||||
Svc[service].runInBatchMode({
|
||||
runBatched: function wrappedSync() {
|
||||
try {
|
||||
engineType.prototype._sync.call(engine);
|
||||
}
|
||||
catch(ex) {
|
||||
batchEx = ex;
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
|
||||
// Expose the exception if something inside the batch failed
|
||||
if (batchEx!= null)
|
||||
throw batchEx;
|
||||
};
|
||||
},
|
||||
|
||||
// Generates a brand-new globally unique identifier (GUID).
|
||||
makeGUID: function makeGUID() {
|
||||
let uuidgen = Cc["@mozilla.org/uuid-generator;1"].
|
||||
@ -488,6 +511,25 @@ let Utils = {
|
||||
return url;
|
||||
},
|
||||
|
||||
// ensures url ends with a slash, optionally adds an extra string at the end
|
||||
slashify: function Weave_slashify(url, extra) {
|
||||
if (url[url.length-1] != '/')
|
||||
url += '/';
|
||||
if (extra)
|
||||
url += extra;
|
||||
return url;
|
||||
},
|
||||
|
||||
//
|
||||
getURLPref: function Weave_getURLPref(pref, def, extra) {
|
||||
let url = Svc.Prefs.get(pref);
|
||||
if (!url && typeof(def) == "undefined")
|
||||
throw pref + " not set";
|
||||
else if (!url)
|
||||
return def;
|
||||
return Utils.slashify(url, extra);
|
||||
},
|
||||
|
||||
xpath: function Weave_xpath(xmlDoc, xpathString) {
|
||||
let root = xmlDoc.ownerDocument == null ?
|
||||
xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement;
|
||||
@ -672,10 +714,6 @@ let Utils = {
|
||||
this.openDialog("ChangeSomething", "generic-change.xul");
|
||||
},
|
||||
|
||||
openShare: function Utils_openShare() {
|
||||
Utils.openDialog("Share", "share.xul");
|
||||
},
|
||||
|
||||
openLog: function Utils_openLog() {
|
||||
Utils._openChromeWindow("Log", "log.xul");
|
||||
},
|
||||
@ -687,6 +725,32 @@ let Utils = {
|
||||
Utils._openChromeWindow("Sync", "pick-sync.xul");
|
||||
},
|
||||
|
||||
__errorBundle: null,
|
||||
get _errorBundle() {
|
||||
if (!this.__errorBundle) {
|
||||
this.__errorBundle = new StringBundle("chrome://weave/locales/errors.properties");
|
||||
}
|
||||
return this.__errorBundle;
|
||||
},
|
||||
|
||||
getErrorString: function Utils_getErrorString(error, args) {
|
||||
switch (error) {
|
||||
case Weave.LOGIN_FAILED_NETWORK_ERROR:
|
||||
errorString = "error.login.reason.network";
|
||||
break;
|
||||
case Weave.LOGIN_FAILED_INVALID_PASSPHRASE:
|
||||
errorString = "error.login.reason.passphrase";
|
||||
break;
|
||||
case Weave.LOGIN_FAILED_LOGIN_REJECTED:
|
||||
errorString = "error.login.reason.password";
|
||||
break;
|
||||
default:
|
||||
errorString = "error.login.reason.unknown";
|
||||
break;
|
||||
}
|
||||
return this._errorBundle.get(errorString, args || null);
|
||||
},
|
||||
|
||||
// assumes an nsIConverterInputStream
|
||||
readStream: function Weave_readStream(is) {
|
||||
let ret = "", str = {};
|
||||
|
@ -1,5 +1,6 @@
|
||||
pref("extensions.weave.serverURL", "https://auth.services.mozilla.com/");
|
||||
pref("extensions.weave.tmpServerURL", "https://services.mozilla.com/");
|
||||
pref("extensions.weave.serverURL", "https://auth.services.mozilla.com/user/");
|
||||
pref("extensions.weave.miscURL", "https://auth.services.mozilla.com/misc/");
|
||||
pref("extensions.weave.termsURL", "https://labs.mozilla.com/projects/weave/tos/");
|
||||
|
||||
pref("extensions.weave.encryption", "aes-256-cbc");
|
||||
|
||||
|
@ -41,7 +41,7 @@ function run_test() {
|
||||
let res = new Resource("http://localhost:8080/foo");
|
||||
let content = res.get();
|
||||
do_check_eq(content, "This path exists and is protected");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
|
||||
server.stop();
|
||||
}
|
||||
|
19
services/sync/tests/unit/test_bookmark_batch_fail.js
Normal file
19
services/sync/tests/unit/test_bookmark_batch_fail.js
Normal file
@ -0,0 +1,19 @@
|
||||
_("Making sure a failing sync reports a useful error");
|
||||
Cu.import("resource://weave/engines/bookmarks.js");
|
||||
|
||||
function run_test() {
|
||||
let engine = new BookmarksEngine();
|
||||
engine._syncStartup = function() {
|
||||
throw "FAIL!";
|
||||
};
|
||||
|
||||
try {
|
||||
_("Try calling the sync that should throw right away");
|
||||
engine._sync();
|
||||
do_throw("Should have failed sync!");
|
||||
}
|
||||
catch(ex) {
|
||||
_("Making sure what we threw ended up as the exception:", ex);
|
||||
do_check_eq(ex, "FAIL!");
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ function run_test() {
|
||||
|
||||
_("Parse empty string payload as deleted");
|
||||
called = false;
|
||||
stream._data = '[{"payload":""}]';
|
||||
stream._data = '{"payload":""}\n';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
_("Got record:", JSON.stringify(rec));
|
||||
@ -23,7 +23,7 @@ function run_test() {
|
||||
|
||||
_("Parse record with payload");
|
||||
called = false;
|
||||
stream._data = '[{"payload":"{\\"value\\":123}"}]';
|
||||
stream._data = '{"payload":"{\\"value\\":123}"}\n';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
_("Got record:", JSON.stringify(rec));
|
||||
@ -39,7 +39,7 @@ function run_test() {
|
||||
called = false;
|
||||
recCount = 0;
|
||||
sum = 0;
|
||||
stream._data = '[{"payload":"{\\"value\\":100}"},{"payload":"{\\"value\\":10}"},{"payload":"{\\"value\\":1}"}]';
|
||||
stream._data = '{"payload":"{\\"value\\":100}"}\n{"payload":"{\\"value\\":10}"}\n{"payload":"{\\"value\\":1}"}\n';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
_("Got record:", JSON.stringify(rec));
|
||||
@ -76,7 +76,7 @@ function run_test() {
|
||||
called = false;
|
||||
recCount = 0;
|
||||
sum = 0;
|
||||
stream._data = '[{"payl';
|
||||
stream._data = '{"payl';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
do_throw("shouldn't have gotten a record..");
|
||||
@ -92,7 +92,7 @@ function run_test() {
|
||||
|
||||
_("adding more data enough for one record..");
|
||||
called = false;
|
||||
stream._data += 'oad":"{\\"value\\":100}"},';
|
||||
stream._data += 'oad":"{\\"value\\":100}"}\n';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
_("Got record:", JSON.stringify(rec));
|
||||
@ -126,7 +126,7 @@ function run_test() {
|
||||
|
||||
_("add data for two records..");
|
||||
called = false;
|
||||
stream._data += '},{"payload":"{\\"value\\":1}"}';
|
||||
stream._data += '}\n{"payload":"{\\"value\\":1}"}\n';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
_("Got record:", JSON.stringify(rec));
|
||||
@ -155,9 +155,9 @@ function run_test() {
|
||||
do_check_true(called);
|
||||
_();
|
||||
|
||||
_("add ending array bracket");
|
||||
_("add no extra data");
|
||||
called = false;
|
||||
stream._data += ']';
|
||||
stream._data += '';
|
||||
coll.recordHandler = function(rec) {
|
||||
called = true;
|
||||
do_throw("shouldn't have gotten a record..");
|
||||
@ -166,7 +166,7 @@ function run_test() {
|
||||
_("should still have 3 records with sum 111");
|
||||
do_check_eq(recCount, 3);
|
||||
do_check_eq(sum, 111);
|
||||
_("should have consumed the last array bracket");
|
||||
_("should have consumed nothing but still have nothing");
|
||||
do_check_eq(stream._data, "");
|
||||
do_check_false(called);
|
||||
_("\n");
|
||||
|
@ -1,13 +0,0 @@
|
||||
function run_test() {
|
||||
Components.utils.import("resource://weave/log4moz.js");
|
||||
Components.utils.import("resource://weave/faultTolerance.js");
|
||||
|
||||
// Just make sure the getter works and the service is a singleton.
|
||||
FaultTolerance.Service._testProperty = "hi";
|
||||
do_check_eq(FaultTolerance.Service._testProperty, "hi");
|
||||
|
||||
var log = Log4Moz.repository.rootLogger;
|
||||
log.level = Log4Moz.Level.All;
|
||||
log.info("Testing.");
|
||||
do_check_eq(Log4Moz.repository.rootLogger.appenders.length, 1);
|
||||
}
|
@ -21,7 +21,6 @@ const modules = [
|
||||
"engines.js",
|
||||
"ext/Observers.js",
|
||||
"ext/Preferences.js",
|
||||
"faultTolerance.js",
|
||||
"identity.js",
|
||||
"log4moz.js",
|
||||
"notifications.js",
|
||||
|
@ -43,13 +43,13 @@ function run_test() {
|
||||
|
||||
let pubkey = PubKeys.get("http://localhost:8080/pubkey");
|
||||
do_check_eq(pubkey.data.payload.type, "pubkey");
|
||||
do_check_eq(PubKeys.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(PubKeys.response.status, 200);
|
||||
|
||||
log.info("Getting matching private key");
|
||||
|
||||
let privkey = PrivKeys.get(pubkey.privateKeyUri);
|
||||
do_check_eq(privkey.data.payload.type, "privkey");
|
||||
do_check_eq(PrivKeys.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(PrivKeys.response.status, 200);
|
||||
|
||||
log.info("Done!");
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ function run_test() {
|
||||
log.info("Getting a WBO record");
|
||||
|
||||
let res = new Resource("http://localhost:8080/record");
|
||||
res.get();
|
||||
let resp = res.get();
|
||||
|
||||
let rec = new WBORecord();
|
||||
rec.deserialize(res.data);
|
||||
@ -60,7 +60,7 @@ function run_test() {
|
||||
do_check_eq(rec.modified, 2454725.98283);
|
||||
do_check_eq(typeof(rec.payload), "object");
|
||||
do_check_eq(rec.payload.cheese, "roquefort");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(resp.status, 200);
|
||||
|
||||
log.info("Getting a WBO record using the record manager");
|
||||
|
||||
@ -69,7 +69,7 @@ function run_test() {
|
||||
do_check_eq(rec2.modified, 2454725.98284);
|
||||
do_check_eq(typeof(rec2.payload), "object");
|
||||
do_check_eq(rec2.payload.cheese, "gruyere");
|
||||
do_check_eq(Records.lastResource.lastChannel.responseStatus, 200);
|
||||
do_check_eq(Records.response.status, 200);
|
||||
|
||||
log.info("Done!");
|
||||
}
|
||||
|
@ -56,14 +56,15 @@ function run_test() {
|
||||
let res = new Resource("http://localhost:8080/open");
|
||||
let content = res.get();
|
||||
do_check_eq(content, "This path exists");
|
||||
do_check_eq(res.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
do_check_true(content.success);
|
||||
|
||||
// 2. A password protected resource (test that it'll fail w/o pass)
|
||||
// 2. A password protected resource (test that it'll fail w/o pass, no throw)
|
||||
let res2 = new Resource("http://localhost:8080/protected");
|
||||
try {
|
||||
content = res2.get();
|
||||
do_check_true(false); // unreachable, get() above must fail
|
||||
} catch (e) {}
|
||||
content = res2.get();
|
||||
do_check_eq(content, "This path exists and is protected - failed")
|
||||
do_check_eq(content.status, 401);
|
||||
do_check_false(content.success);
|
||||
|
||||
// 3. A password protected resource
|
||||
|
||||
@ -72,17 +73,21 @@ function run_test() {
|
||||
res3.authenticator = auth;
|
||||
content = res3.get();
|
||||
do_check_eq(content, "This path exists and is protected");
|
||||
do_check_eq(res3.lastChannel.responseStatus, 200);
|
||||
do_check_eq(content.status, 200);
|
||||
do_check_true(content.success);
|
||||
|
||||
// 4. A non-existent resource (test that it'll fail)
|
||||
// 4. A non-existent resource (test that it'll fail, but not throw)
|
||||
|
||||
let res4 = new Resource("http://localhost:8080/404");
|
||||
try {
|
||||
let content = res4.get();
|
||||
do_check_true(false); // unreachable, get() above must fail
|
||||
} catch (e) {}
|
||||
do_check_eq(res4.lastChannel.responseStatusText, "Not Found");
|
||||
do_check_eq(res4.lastChannel.responseStatus, 404);
|
||||
content = res4.get();
|
||||
do_check_eq(content, "File not found");
|
||||
do_check_eq(content.status, 404);
|
||||
do_check_false(content.success);
|
||||
|
||||
_("5. Check some headers of the 404 response");
|
||||
do_check_eq(content.headers.Connection, "close");
|
||||
do_check_eq(content.headers.Server, "httpd.js");
|
||||
do_check_eq(content.headers["Content-Length"], 14);
|
||||
|
||||
// FIXME: additional coverage needed:
|
||||
// * PUT requests
|
||||
|
Loading…
Reference in New Issue
Block a user