Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
officejs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
officejs
Commits
77635b7a
Commit
77635b7a
authored
Jun 27, 2012
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding Qunit tests and corrections to conflict and crypt storage.
parent
b43c7be2
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
1475 additions
and
1292 deletions
+1475
-1292
OfficeJS/lib/jio/jio.storage.js
OfficeJS/lib/jio/jio.storage.js
+583
-564
OfficeJS/lib/jio/jio.storage.min.js
OfficeJS/lib/jio/jio.storage.min.js
+2
-2
OfficeJS/src/jio.storage/conflictmanagerstorage.js
OfficeJS/src/jio.storage/conflictmanagerstorage.js
+536
-524
OfficeJS/src/jio.storage/cryptstorage.js
OfficeJS/src/jio.storage/cryptstorage.js
+43
-36
OfficeJS/test/jiotests.js
OfficeJS/test/jiotests.js
+311
-166
No files found.
OfficeJS/lib/jio/jio.storage.js
View file @
77635b7a
This diff is collapsed.
Click to expand it.
OfficeJS/lib/jio/jio.storage.min.js
View file @
77635b7a
This diff is collapsed.
Click to expand it.
OfficeJS/src/jio.storage/conflictmanagerstorage.js
View file @
77635b7a
This diff is collapsed.
Click to expand it.
OfficeJS/src/jio.storage/cryptstorage.js
View file @
77635b7a
var
newCryptedStorage
=
function
(
spec
,
my
)
{
var
that
=
Jio
.
storage
(
spec
,
my
,
'
handler
'
),
priv
=
{};
var
is_valid_storage
=
spec
.
storage
||
false
;
priv
.
username
=
spec
.
username
||
''
;
priv
.
password
=
spec
.
password
||
''
;
priv
.
secondstorage_spec
=
spec
.
storage
||
{
type
:
'
base
'
};
priv
.
secondstorage_string
=
JSON
.
stringify
(
priv
.
secondstorage_string
);
var
super_serialized
=
that
.
serialized
;
that
.
serialized
=
function
()
{
var
o
=
super_serialized
();
o
.
username
=
priv
.
username
;
o
.
password
=
priv
.
password
;
o
.
storage
=
priv
.
secondstorage_string
;
return
o
;
};
that
.
validateState
=
function
()
{
if
(
priv
.
username
&&
JSON
.
stringify
(
priv
.
secondstorage_spec
)
===
JSON
.
stringify
({
type
:
'
base
'
}))
{
if
(
priv
.
username
&&
is_valid_storage
)
{
return
''
;
}
return
'
Need at least two parameters: "username" and "storage".
'
;
...
...
@@ -44,8 +46,8 @@ var newCryptedStorage = function ( spec, my ) {
priv
.
encrypt
=
function
(
data
,
callback
,
index
)
{
// end with a callback in order to improve encrypt to an
// asynchronous encryption.
var
tmp
=
sjcl
.
encrypt
(
that
.
getStorageUserName
()
+
'
:
'
+
that
.
getStoragePassword
()
,
data
,
var
tmp
=
sjcl
.
encrypt
(
priv
.
username
+
'
:
'
+
priv
.
password
,
data
,
priv
.
encrypt_param_object
);
callback
(
JSON
.
parse
(
tmp
).
ct
,
index
);
};
...
...
@@ -54,8 +56,8 @@ var newCryptedStorage = function ( spec, my ) {
param
.
ct
=
data
||
''
;
param
=
JSON
.
stringify
(
param
);
try
{
tmp
=
sjcl
.
decrypt
(
that
.
getStorageUserName
()
+
'
:
'
+
that
.
getStoragePassword
()
,
tmp
=
sjcl
.
decrypt
(
priv
.
username
+
'
:
'
+
priv
.
password
,
param
);
}
catch
(
e
)
{
callback
({
status
:
0
,
statusText
:
'
Decrypt Fail
'
,
...
...
@@ -70,7 +72,7 @@ var newCryptedStorage = function ( spec, my ) {
* @method saveDocument
*/
that
.
saveDocument
=
function
(
command
)
{
var
new_file_name
,
new
file
content
,
var
new_file_name
,
new
_file_
content
,
_1
=
function
()
{
priv
.
encrypt
(
command
.
getPath
(),
function
(
res
)
{
new_file_name
=
res
;
...
...
@@ -79,21 +81,21 @@ var newCryptedStorage = function ( spec, my ) {
},
_2
=
function
()
{
priv
.
encrypt
(
command
.
getContent
(),
function
(
res
)
{
new
file
content
=
res
;
new
_file_
content
=
res
;
_3
();
});
},
_3
=
function
()
{
var
settings
=
that
.
cloneOption
(),
newcommand
,
newstorage
;
var
settings
=
command
.
cloneOption
(),
newcommand
;
settings
.
onResponse
=
function
(){};
settings
.
onDone
=
function
()
{
that
.
done
();
};
settings
.
onFail
=
function
(
r
)
{
that
.
fail
(
r
);
};
newcommand
=
that
.
newCommand
(
{
path
:
new_file_name
,
content
:
newfilecontent
,
option
:
settings
});
newstorage
=
that
.
newStorage
(
priv
.
secondstorage_spec
);
that
.
addJob
(
newstorage
,
newcommand
);
'
saveDocument
'
,
{
path
:
new_file_name
,
content
:
new_file_content
,
option
:
settings
});
that
.
addJob
(
that
.
newStorage
(
priv
.
secondstorage_spec
),
newcommand
);
};
_1
();
};
// end saveDocument
...
...
@@ -111,22 +113,22 @@ var newCryptedStorage = function ( spec, my ) {
});
},
_2
=
function
()
{
var
settings
=
command
.
cloneOption
(),
newcommand
,
newstorage
;
var
settings
=
command
.
cloneOption
(),
newcommand
;
settings
.
onResponse
=
function
(){};
settings
.
onFail
=
loadOnFail
;
settings
.
onDone
=
loadOnDone
;
newcommand
=
that
.
newCommand
(
{
path
:
new_file_name
,
option
:
settings
});
newstorage
=
that
.
newStorage
(
priv
.
secondstorage_spec
);
that
.
addJob
(
newstorage
,
newcommand
);
'
loadDocument
'
,
{
path
:
new_file_name
,
option
:
settings
});
that
.
addJob
(
that
.
newStorage
(
priv
.
secondstorage_spec
)
,
newcommand
);
},
loadOnDone
=
function
(
result
)
{
result
.
name
=
command
.
getPath
();
if
(
command
.
getOption
(
'
metadata_only
'
))
{
that
.
done
(
result
);
}
else
{
priv
.
decrypt
(
result
.
content
,
function
(
res
){
priv
.
decrypt
(
result
.
content
,
function
(
res
){
if
(
typeof
res
===
'
object
'
)
{
that
.
fail
({
status
:
0
,
statusText
:
'
Decrypt Fail
'
,
message
:
'
Unable to decrypt
'
});
...
...
@@ -140,11 +142,11 @@ var newCryptedStorage = function ( spec, my ) {
});
}
},
loadOnFail
=
function
(
result
)
{
loadOnFail
=
function
(
error
)
{
// NOTE : we can re create an error object instead of
// keep the old ex:status=404,message="document 1y59gyl8g
// not found in localStorage"...
that
.
fail
(
result
);
that
.
fail
(
error
);
};
_1
();
};
// end loadDocument
...
...
@@ -156,16 +158,16 @@ var newCryptedStorage = function ( spec, my ) {
that
.
getDocumentList
=
function
(
command
)
{
var
new_job
,
i
,
l
,
cpt
=
0
,
array
,
ok
=
true
,
_1
=
function
()
{
var
newcommand
=
command
.
clone
(),
newstorage
=
that
.
newStorage
(
priv
.
secondstorage_spec
);
var
newcommand
=
command
.
clone
();
newcommand
.
onResponseDo
(
getListOnResponse
);
newcommand
.
onDoneDo
(
function
(){});
newcommand
.
onFailDo
(
function
(){});
that
.
addJob
(
new_job
);
that
.
addJob
(
that
.
newStorage
(
priv
.
secondstorage_spec
),
newcommand
);
},
getListOnResponse
=
function
(
result
)
{
if
(
result
.
status
.
isDone
())
{
array
=
result
.
return_
value
;
array
=
result
.
value
;
for
(
i
=
0
,
l
=
array
.
length
;
i
<
l
;
i
+=
1
)
{
// cpt--;
priv
.
decrypt
(
array
[
i
].
name
,
...
...
@@ -182,6 +184,7 @@ var newCryptedStorage = function ( spec, my ) {
cpt
++
;
if
(
typeof
res
===
'
object
'
)
{
if
(
ok
)
{
ok
=
false
;
that
.
fail
({
status
:
0
,
statusText
:
'
Decrypt Fail
'
,
message
:
'
Unable to decrypt.
'
});
}
...
...
@@ -201,23 +204,27 @@ var newCryptedStorage = function ( spec, my ) {
* Removes a document.
* @method removeDocument
*/
that
.
removeDocument
=
function
()
{
var
new_
job
,
new_
file_name
,
that
.
removeDocument
=
function
(
command
)
{
var
new_file_name
,
_1
=
function
()
{
priv
.
encrypt
(
that
.
getFileName
(),
function
(
res
)
{
priv
.
encrypt
(
command
.
getPath
(),
function
(
res
)
{
new_file_name
=
res
;
_2
();
});
},
_2
=
function
()
{
new_job
=
that
.
cloneJob
();
new_job
.
name
=
new_file_name
;
new_job
.
storage
=
that
.
getSecondStorage
();
new_job
.
onResponse
=
removeOnResponse
;
that
.
addJob
(
new_job
);
var
cloned_option
=
command
.
cloneOption
();
cloned_option
.
onResponse
=
removeOnResponse
;
cloned_option
.
onFail
=
function
()
{};
cloned_option
.
onDone
=
function
()
{};
that
.
addJob
(
that
.
newStorage
(
priv
.
secondstorage_spec
),
that
.
newCommand
(
'
removeDocument
'
,
{
path
:
new_file_name
,
option
:
cloned_option
}));
},
removeOnResponse
=
function
(
result
)
{
if
(
result
.
status
===
'
done
'
)
{
if
(
result
.
status
.
isDone
()
)
{
that
.
done
();
}
else
{
that
.
fail
(
result
.
error
);
...
...
OfficeJS/test/jiotests.js
View file @
77635b7a
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment