Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
Merge 3139af6 into f1070e5
Browse files Browse the repository at this point in the history
  • Loading branch information
ralphtheninja committed Nov 14, 2018
2 parents f1070e5 + 3139af6 commit 2dda8d4
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 64 deletions.
32 changes: 16 additions & 16 deletions README.md
Expand Up @@ -91,7 +91,7 @@ dc.open(() => {
dc.once('ready', onReady)
dc.configure({
addr: 'user@site.org',
mail_pw: 'password'
mailPw: 'password'
})
} else {
onReady()
Expand Down Expand Up @@ -166,21 +166,21 @@ Configure and connect a context. Corresponds to [`dc_configure()`](https://c.del
The `options` object takes the following properties:

* `options.addr` *(string, required)*: Email address of the chat user.
* `options.mail_server` *(string, optional)*: IMAP-server, guessed if left out.
* `options.mail_user` *(string, optional)*: IMAP-username, guessed if left out.
* `options.mail_pw` *(string, required)*: IMAP-password of the chat user.
* `options.mail_port` *(string | integer, optional)*: IMAP-port, guessed if left out.
* `options.send_server` *(string, optional)*: SMTP-server, guessed if left out.
* `options.send_user` *(string, optional)*: SMTP-user, guessed if left out.
* `options.send_pw` *(string, optional)*: SMTP-password, guessed if left out.
* `options.send_port` *(string | integer, optional)*: SMTP-port, guessed if left out.
* `options.server_flags` *(integer, optional)*: IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out.
* `options.displayname` *(string, optional)*: Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty.
* `options.selfstatus` *(string, optional)*: Own status to display e.g. in email footers, defaults to a standard text.
* `options.selfavatar` *(string, optional)*: File containing avatar.
* `options.e2ee_enabled` *(boolean, optional)*: Enable E2EE. Defaults to `true`.
* `options.mdns_enabled` *(boolean, optional)*: Send and request read receipts. Defaults to `true`.
* `options.save_mime_headers` *(boolean, optional)*: Set to `true` if you want to use [`dc.getMimeHeaders()`](#getmimeheaders) later.
* `options.mailServer` *(string, optional)*: IMAP-server, guessed if left out.
* `options.mailUser` *(string, optional)*: IMAP-username, guessed if left out.
* `options.mailPw` *(string, required)*: IMAP-password of the chat user.
* `options.mailPort` *(string | integer, optional)*: IMAP-port, guessed if left out.
* `options.sendServer` *(string, optional)*: SMTP-server, guessed if left out.
* `options.sendUser` *(string, optional)*: SMTP-user, guessed if left out.
* `options.sendPw` *(string, optional)*: SMTP-password, guessed if left out.
* `options.sendPort` *(string | integer, optional)*: SMTP-port, guessed if left out.
* `options.serverFlags` *(integer, optional)*: IMAP-/SMTP-flags as a combination of DC_LP flags, guessed if left out.
* `options.displayName` *(string, optional)*: Own name to use when sending messages. MUAs are allowed to spread this way e.g. using CC, defaults to empty.
* `options.selfStatus` *(string, optional)*: Own status to display e.g. in email footers, defaults to a standard text.
* `options.selfAvatar` *(string, optional)*: File containing avatar.
* `options.e2eeEnabled` *(boolean, optional)*: Enable E2EE. Defaults to `true`.
* `options.mdnsEnabled` *(boolean, optional)*: Send and request read receipts. Defaults to `true`.
* `options.saveMimeHeaders` *(boolean, optional)*: Set to `true` if you want to use [`dc.getMimeHeaders()`](#getmimeheaders) later.

#### `dc.continueKeyTransfer(messageId, setupCode, callback)`

Expand Down
39 changes: 20 additions & 19 deletions index.js
Expand Up @@ -102,32 +102,33 @@ class DeltaChat extends EventEmitter {
throw new Error('Missing .addr')
}

if (typeof opts.mail_pw !== 'string') {
throw new Error('Missing .mail_pw')
if (typeof opts.mailPw !== 'string') {
throw new Error('Missing .mailPw')
}

this.once('_configured', ready)

if (typeof opts.e2ee_enabled === 'undefined') opts.e2ee_enabled = 1
if (typeof opts.e2eeEnabled === 'undefined') opts.e2eeEnabled = 1

this.setConfig('addr', opts.addr)

this.setConfig('mail_server', opts.mail_server)
this.setConfig('mail_user', opts.mail_user)
this.setConfig('mail_port', String(opts.mail_port))

this.setConfig('mail_pw', opts.mail_pw)
this.setConfig('send_server', opts.send_server)
this.setConfig('send_user', opts.send_user)
this.setConfig('send_pw', opts.send_pw)
this.setConfig('send_port', String(opts.send_port))
this.setConfig('server_flags', String(opts.server_flags))
this.setConfig('displayname', opts.displayname)
this.setConfig('selfstatus', opts.selfstatus)
this.setConfig('selfavatar', opts.selfavatar)
this.setConfig('e2ee_enabled', String(opts.e2ee_enabled ? 1 : 0))
this.setConfig('mdns_enabled', String(opts.mdns_enabled ? 1 : 0))
this.setConfig('save_mime_headers', String(opts.save_mime_headers ? 1 : 0))
this.setConfig('mail_server', opts.mailServer)
this.setConfig('mail_user', opts.mailUser)
this.setConfig('mail_pw', opts.mailPw)
this.setConfig('mail_port', String(opts.mailPort))

this.setConfig('send_server', opts.sendServer)
this.setConfig('send_user', opts.sendUser)
this.setConfig('send_pw', opts.sendPw)
this.setConfig('send_port', String(opts.sendPort))

this.setConfig('server_flags', String(opts.serverFlags))
this.setConfig('displayname', opts.displayName)
this.setConfig('selfstatus', opts.selfStatus)
this.setConfig('selfavatar', opts.selfAvatar)
this.setConfig('e2ee_enabled', String(opts.e2eeEnabled ? 1 : 0))
this.setConfig('mdns_enabled', String(opts.mdnsEnabled ? 1 : 0))
this.setConfig('save_mime_headers', String(opts.saveMimeHeaders ? 1 : 0))

binding.dcn_configure(this.dcn_context)
}
Expand Down
57 changes: 31 additions & 26 deletions test/integration.js
Expand Up @@ -10,19 +10,24 @@ let dc = null
function configureDefaultDC (dc) {
dc.configure({
addr: 'delta1@delta.localhost',
mail_server: '127.0.0.1',
mail_user: 'delta1',
mail_pw: 'delta1',
mail_port: 3143,
send_server: '127.0.0.1',
send_user: 'delta1',
send_pw: 'delta1',
send_port: 3025,
server_flags: 0x400 | 0x40000,
displayname: 'Delta One',
selfstatus: 'From Delta One with <3',
e2ee_enabled: true,
save_mime_headers: true

mailServer: '127.0.0.1',
mailUser: 'delta1',
mailPw: 'delta1',
mailPort: 3143,

sendServer: '127.0.0.1',
sendUser: 'delta1',
sendPw: 'delta1',
sendPort: 3025,

serverFlags: 0x400 | 0x40000,

displayName: 'Delta One',
selfStatus: 'From Delta One with <3',

e2eeEnabled: true,
saveMimeHeaders: true
})
}

Expand All @@ -38,19 +43,19 @@ test('setUp dc context', t => {
dc = new DeltaChat()
dc.once('ready', () => {
t.is(dc.getConfig('addr'), 'delta1@delta.localhost', 'addr correct')
t.is(dc.getConfig('mail_server'), '127.0.0.1', 'mail_server correct')
t.is(dc.getConfig('mail_port'), '3143', 'mail_port correct')
t.is(dc.getConfig('mail_user'), 'delta1', 'mail_user correct')
t.is(dc.getConfig('mail_pw'), 'delta1', 'mail_pw correct')
t.is(dc.getConfig('send_server'), '127.0.0.1', 'send_server correct')
t.is(dc.getConfig('send_port'), '3025', 'send_port correct')
t.is(dc.getConfig('send_user'), 'delta1', 'send_user correct')
t.is(dc.getConfig('send_pw'), 'delta1', 'send_pw correct')
t.is(dc.getConfig('server_flags'), String(0x400 | 0x40000), 'server_flags correct')
t.is(dc.getConfig('displayname'), 'Delta One', 'displayname correct')
t.is(dc.getConfig('selfstatus'), 'From Delta One with <3', 'selfstatus correct')
t.is(dc.getConfig('e2ee_enabled'), '1', 'e2ee enabled')
t.is(dc.getConfig('save_mime_headers'), '1', 'saving mime headers enabled')
t.is(dc.getConfig('mail_server'), '127.0.0.1', 'mailServer correct')
t.is(dc.getConfig('mail_port'), '3143', 'mailPort correct')
t.is(dc.getConfig('mail_user'), 'delta1', 'mailUser correct')
t.is(dc.getConfig('mail_pw'), 'delta1', 'mailPw correct')
t.is(dc.getConfig('send_server'), '127.0.0.1', 'sendServer correct')
t.is(dc.getConfig('send_port'), '3025', 'sendPort correct')
t.is(dc.getConfig('send_user'), 'delta1', 'sendUser correct')
t.is(dc.getConfig('send_pw'), 'delta1', 'sendPw correct')
t.is(dc.getConfig('server_flags'), String(0x400 | 0x40000), 'serverFlags correct')
t.is(dc.getConfig('displayname'), 'Delta One', 'displayName correct')
t.is(dc.getConfig('selfstatus'), 'From Delta One with <3', 'selfStatus correct')
t.is(dc.getConfig('e2ee_enabled'), '1', 'e2eeEnabled correct')
t.is(dc.getConfig('save_mime_headers'), '1', 'saveMimeHeaders correct')
t.is(dc.getBlobdir(), `${cwd}/db.sqlite-blobs`, 'correct blobdir')
})
dc.once('DC_EVENT_CONFIGURE_PROGRESS', data => {
Expand Down
6 changes: 3 additions & 3 deletions test/open.js
Expand Up @@ -13,9 +13,9 @@ test('open', t => {
t.test('> missing addr or mail_pw throws', t => {
t.throws(function () {
dc.configure({ addr: 'delta1@delta.localhost' })
}, /Missing \.mail_pw/, 'missing mail_pw throws')
}, /Missing \.mailPw/, 'missing mailPw throws')
t.throws(function () {
dc.configure({ mail_pw: 'delta1' })
dc.configure({ mailPw: 'delta1' })
}, /Missing \.addr/, 'missing addr throws')
t.end()
})
Expand All @@ -32,7 +32,7 @@ test('open', t => {
})
dc.configure({
addr: 'hpk2@hq5.merlinux.eu',
mail_pw: 'whatever'
mailPw: 'whatever'
})
})

Expand Down

0 comments on commit 2dda8d4

Please sign in to comment.