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
139ab0be
Commit
139ab0be
authored
Sep 01, 2011
by
François Billioud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
propose different storage nodes not tested yet
parent
ad9d385a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
282 additions
and
219 deletions
+282
-219
UNGProject/unhosted/jio.js
UNGProject/unhosted/jio.js
+282
-219
No files found.
UNGProject/unhosted/jio.js
View file @
139ab0be
...
@@ -552,15 +552,8 @@
...
@@ -552,15 +552,8 @@
}
}
getIndex
:
function
()
{
return
this
.
index
},
/***************************************************************
save
:
function
()
{
*********************** CryptedStorage *************************/
this
.
storage
.
saveDocument
(
JSON
.
stringify
(
this
.
getIndex
()),
"
jio.index
"
,
"
text
"
,
true
);
}
}
/***************************************************************
*********************** CryptedStorage *************************/
/**
/**
* Class CryptedStorage
* Class CryptedStorage
* @class provides usual API to encrypte data storing documents
* @class provides usual API to encrypte data storing documents
...
@@ -570,30 +563,100 @@
...
@@ -570,30 +563,100 @@
* "method" : (optional) the algorythm to use - Only sjcl available for the moment
* "method" : (optional) the algorythm to use - Only sjcl available for the moment
* @param applicant : object containing inforamtion about the person/application needing this JIO object
* @param applicant : object containing inforamtion about the person/application needing this JIO object
*/
*/
JIO
.
Replicate
Storage
=
function
(
data
,
applicant
)
{
JIO
.
Crypted
Storage
=
function
(
data
,
applicant
)
{
this
.
storage
=
createStorage
(
data
.
storage
,
applicant
);
this
.
storage
=
createStorage
(
data
.
storage
,
applicant
);
this
.
password
=
data
.
password
;
this
.
password
=
data
.
password
;
}
}
JIO
.
Replicate
Storage
.
prototype
=
{
JIO
.
Crypted
Storage
.
prototype
=
{
userNameAvailable
:
function
(
name
,
option
)
{
return
this
.
storage
.
userNameAvailable
.
apply
(
this
.
storage
,
arguments
)},
userNameAvailable
:
function
(
name
,
option
)
{
return
this
.
storage
.
userNameAvailable
.
apply
(
this
.
storage
,
arguments
)},
loadDocument
:
function
(
fileName
,
option
)
{
loadDocument
:
function
(
fileName
,
option
)
{
var
cryptedStorage
=
this
;
var
cryptedStorage
=
this
;
var
newOption
=
copy
(
option
);
var
newOption
=
copy
(
option
);
newOption
.
success
=
function
(
data
)
{
newOption
.
success
=
function
(
data
)
{
if
(
option
.
success
)
{
option
.
success
(
sjcl
.
decrypt
(
data
,
cryptedStorage
.
password
))}
//case asynchronous
if
(
option
.
success
)
{
option
.
success
(
sjcl
.
decrypt
(
cryptedStorage
.
password
,
data
))}
//case asynchronous
}
}
var
data
=
this
.
storage
.
loadDocument
(
fileName
,
newOption
);
var
data
=
this
.
storage
.
loadDocument
(
fileName
,
newOption
);
return
data
?
sjcl
.
decrypt
(
data
,
cryptedStorage
.
password
)
:
data
//case synchronous
return
data
?
sjcl
.
decrypt
(
cryptedStorage
.
password
,
data
)
:
data
//case synchronous
},
},
saveDocument
:
function
(
data
,
fileName
,
option
)
{
saveDocument
:
function
(
data
,
fileName
,
option
)
{
return
this
.
storage
.
saveDocument
(
sjcl
.
encrypt
(
data
,
this
.
password
),
fileName
,
option
)
var
encryptedData
=
sjcl
.
encrypt
(
this
.
password
,
data
);
return
this
.
storage
.
saveDocument
(
encryptedData
,
fileName
,
option
)
},
},
deleteDocument
:
function
(
file
,
option
)
{
return
this
.
storage
.
deleteDocument
.
apply
(
this
.
storage
,
arguments
)},
deleteDocument
:
function
(
file
,
option
)
{
return
this
.
storage
.
deleteDocument
.
apply
(
this
.
storage
,
arguments
)},
getDocumentList
:
function
(
option
)
{
return
this
.
storage
.
getDocumentList
.
apply
(
this
.
storage
,
arguments
)}
getDocumentList
:
function
(
option
)
{
return
this
.
storage
.
getDocumentList
.
apply
(
this
.
storage
,
arguments
)}
}
}
/***************************************************************
*********************** ReplicateStorage *************************/
/***************************************************************
*********************** AsynchronousStorage *************************/
/**
* Class AsynchronousStorage
* @class manage the pending list of requests
* @param data : object containing every element needed to build the storage :
* "storage" : the storage to manage
* @param applicant : object containing inforamtion about the person/application needing this JIO object
*/
JIO
.
AsynchronousStorage
=
function
(
data
,
applicant
)
{
this
.
storage
=
createStorage
(
data
.
storage
,
applicant
);
this
.
pendingList
=
{};
//contains the list of pending actions
}
JIO
.
AsynchronousStorage
.
prototype
=
{
userNameAvailable
:
function
(
name
,
option
)
{
var
asynchronousStorage
=
this
;
var
requestID
=
this
.
addPendingAction
(
this
.
userNameAvailable
,
arguments
);
var
instruction
=
function
()
{
asynchronousStorage
.
removePendingAction
(
requestID
)}
option
.
success
=
addInstruction
(
instruction
,
option
.
success
,
true
);
option
.
errorHandler
=
addInstruction
(
instruction
,
option
.
errorHandler
,
true
);
return
this
.
storage
.
userNameAvailable
(
name
,
option
);
},
loadDocument
:
function
(
fileName
,
option
)
{
var
asynchronousStorage
=
this
;
var
requestID
=
this
.
addPendingAction
(
this
.
loadDocument
,
arguments
);
var
instruction
=
function
()
{
asynchronousStorage
.
removePendingAction
(
requestID
)}
option
.
success
=
addInstruction
(
instruction
,
option
.
success
,
true
);
option
.
errorHandler
=
addInstruction
(
instruction
,
option
.
errorHandler
,
true
);
return
this
.
storage
.
loadDocument
(
fileName
,
option
);
},
saveDocument
:
function
(
data
,
fileName
,
option
)
{
var
asynchronousStorage
=
this
;
var
requestID
=
this
.
addPendingAction
(
this
.
saveDocument
,
arguments
);
var
instruction
=
function
()
{
asynchronousStorage
.
removePendingAction
(
requestID
)}
option
.
success
=
addInstruction
(
instruction
,
option
.
success
,
true
);
option
.
errorHandler
=
addInstruction
(
instruction
,
option
.
errorHandler
,
true
);
return
this
.
storage
.
saveDocument
(
data
,
fileName
,
option
);
},
deleteDocument
:
function
(
file
,
option
)
{
var
asynchronousStorage
=
this
;
var
requestID
=
this
.
addPendingAction
(
this
.
deleteDocument
,
arguments
);
var
instruction
=
function
()
{
asynchronousStorage
.
removePendingAction
(
requestID
)}
option
.
success
=
addInstruction
(
instruction
,
option
.
success
,
true
);
option
.
errorHandler
=
addInstruction
(
instruction
,
option
.
errorHandler
,
true
);
return
this
.
storage
.
deleteDocument
(
file
,
option
);
},
getDocumentList
:
function
(
option
)
{
var
asynchronousStorage
=
this
;
var
requestID
=
this
.
addPendingAction
(
this
.
getDocumentList
,
arguments
);
var
instruction
=
function
()
{
asynchronousStorage
.
removePendingAction
(
requestID
)}
option
.
success
=
addInstruction
(
instruction
,
option
.
success
,
true
);
option
.
errorHandler
=
addInstruction
(
instruction
,
option
.
errorHandler
,
true
);
return
this
.
storage
.
getDocumentList
(
option
);
},
addPendingAction
:
function
(
action
,
argument
)
{
var
ID
=
Date
.
now
();
var
task
=
{
action
:
action
,
arguments
:
argument
}
this
.
getPendingList
()[
ID
]
=
task
;
return
ID
;
},
removePendingAction
:
function
(
ID
)
{
delete
this
.
getPendingList
()[
ID
];
},
getPendingList
:
function
()
{
return
this
.
pendingList
}
}
/***************************************************************
*********************** ReplicateStorage *************************/
/**
/**
* Class ReplicateStorage
* Class ReplicateStorage
* @class provides usual API to replicate save/load/delete in a list of storages
* @class provides usual API to replicate save/load/delete in a list of storages
...
@@ -700,8 +763,8 @@
...
@@ -700,8 +763,8 @@
}
}
}
}
/***************************************************************
/***************************************************************
*********************** MultipleStorage *************************/
*********************** MultipleStorage *************************/
/**
/**
* Class MultipleStorage
* Class MultipleStorage
* @class provides usual API to save/load/delete documents in a list of storages
* @class provides usual API to save/load/delete documents in a list of storages
...
@@ -786,7 +849,7 @@
...
@@ -786,7 +849,7 @@
},
},
updateDocumentList
:
function
()
{
updateDocumentList
:
function
()
{
for
(
var
storage
in
this
.
storageList
)
{
this
.
documentList
[
storage
]
=
this
.
storageList
[
storage
].
getDocumentList
()
}
for
(
var
storage
in
this
.
storageList
)
{
this
.
documentList
[
storage
]
=
this
.
storageList
[
storage
].
getDocumentList
()
}
},
},
analysePath
:
function
(
path
)
{
analysePath
:
function
(
path
)
{
var
storage
=
path
.
shift
();
var
storage
=
path
.
shift
();
...
...
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