[Pkg-owncloud-commits] [owncloud-client] 20/83: Remove useless global varialbe for auth callback.
Sandro Knauß
hefee-guest at moszumanska.debian.org
Sat May 31 11:31:39 UTC 2014
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 1303379c9e5a86a0efc70d2fefc73e49abb049f7
Author: Klaas Freitag <freitag at owncloud.com>
Date: Thu May 22 12:54:14 2014 +0200
Remove useless global varialbe for auth callback.
---
csync/src/csync.c | 2 +-
csync/src/csync_owncloud.c | 48 +++++++++++++++++++++++++----------------
csync/src/csync_owncloud.h | 2 +-
src/owncloudcmd/owncloudcmd.cpp | 1 -
4 files changed, 31 insertions(+), 22 deletions(-)
diff --git a/csync/src/csync.c b/csync/src/csync.c
index 484e165..065d4e1 100644
--- a/csync/src/csync.c
+++ b/csync/src/csync.c
@@ -191,7 +191,7 @@ int csync_init(CSYNC *ctx) {
ctx->local.type = LOCAL_REPLICA;
if ( !ctx->options.local_only_mode) {
- owncloud_init(csync_get_auth_callback(ctx), csync_get_userdata(ctx));
+ owncloud_init(csync_get_userdata(ctx));
ctx->remote.type = REMOTE_REPLICA;
} else {
ctx->remote.type = LOCAL_REPLICA;
diff --git a/csync/src/csync_owncloud.c b/csync/src/csync_owncloud.c
index be0e7b0..bfe1a63 100644
--- a/csync/src/csync_owncloud.c
+++ b/csync/src/csync_owncloud.c
@@ -60,7 +60,7 @@ struct dav_session_s dav_session; /* The DAV Session, initialised in dav_connect
int _connected = 0; /* flag to indicate if a connection exists, ie.
the dav_session is valid */
-csync_auth_callback _authcb;
+
void *_userdata;
long long chunked_total_size = 0;
long long chunked_done = 0;
@@ -123,6 +123,7 @@ static int verify_sslcert(void *userdata, int failures,
char buf[MAX(NE_SSL_DIGESTLEN, NE_ABUFSIZ)];
int ret = -1;
const ne_ssl_certificate *cert = certificate;
+ csync_auth_callback authcb = NULL;
(void) userdata;
memset( problem, 0, LEN );
@@ -160,11 +161,14 @@ static int verify_sslcert(void *userdata, int failures,
}
addSSLWarning( problem, "Do you want to accept the certificate chain anyway?\nAnswer yes to do so and take the risk: ", LEN );
- if( _authcb ){
+ if( dav_session.csync_ctx ) {
+ authcb = csync_get_auth_callback( dav_session.csync_ctx );
+ }
+ if( authcb ){
/* call the csync callback */
DEBUG_WEBDAV("Call the csync callback for SSL problems");
memset( buf, 0, NE_ABUFSIZ );
- (*_authcb) ( problem, buf, NE_ABUFSIZ-1, 1, 0, _userdata );
+ (*authcb) ( problem, buf, NE_ABUFSIZ-1, 1, 0, _userdata );
if( buf[0] == 'y' || buf[0] == 'Y') {
ret = 0;
} else {
@@ -184,6 +188,8 @@ static int ne_auth( void *userdata, const char *realm, int attempt,
char *username, char *password)
{
char buf[NE_ABUFSIZ];
+ csync_auth_callback authcb = NULL;
+ int re = attempt;
(void) userdata;
(void) realm;
@@ -199,24 +205,29 @@ static int ne_auth( void *userdata, const char *realm, int attempt,
if( dav_session.pwd && strlen( dav_session.pwd ) < NE_ABUFSIZ ) {
strcpy( password, dav_session.pwd );
}
- } else if( _authcb != NULL ){
- /* call the csync callback */
- DEBUG_WEBDAV("Call the csync callback for %s", realm );
- memset( buf, 0, NE_ABUFSIZ );
- (*_authcb) ("Enter your username: ", buf, NE_ABUFSIZ-1, 1, 0, _userdata );
- if( strlen(buf) < NE_ABUFSIZ ) {
- strcpy( username, buf );
+ } else {
+ if( dav_session.csync_ctx ) {
+ authcb = csync_get_auth_callback( dav_session.csync_ctx );
}
- memset( buf, 0, NE_ABUFSIZ );
- (*_authcb) ("Enter your password: ", buf, NE_ABUFSIZ-1, 0, 0, _userdata );
- if( strlen(buf) < NE_ABUFSIZ) {
- strcpy( password, buf );
+ if( authcb != NULL ){
+ /* call the csync callback */
+ DEBUG_WEBDAV("Call the csync callback for %s", realm );
+ memset( buf, 0, NE_ABUFSIZ );
+ (*authcb) ("Enter your username: ", buf, NE_ABUFSIZ-1, 1, 0, _userdata );
+ if( strlen(buf) < NE_ABUFSIZ ) {
+ strcpy( username, buf );
+ }
+ memset( buf, 0, NE_ABUFSIZ );
+ (*authcb) ("Enter your password: ", buf, NE_ABUFSIZ-1, 0, 0, _userdata );
+ if( strlen(buf) < NE_ABUFSIZ) {
+ strcpy( password, buf );
+ }
+ } else {
+ re = 1;
}
- } else {
- DEBUG_WEBDAV("I can not authenticate!");
}
}
- return attempt;
+ return re;
}
/*
@@ -1049,10 +1060,9 @@ int owncloud_set_property(const char *key, void *data) {
return -1;
}
-void owncloud_init(csync_auth_callback cb, void *userdata) {
+void owncloud_init(void *userdata) {
_userdata = userdata;
- _authcb = cb;
_connected = 0; /* triggers dav_connect to go through the whole neon setup */
memset(&dav_session, 0, sizeof(dav_session));
diff --git a/csync/src/csync_owncloud.h b/csync/src/csync_owncloud.h
index 745e3af..fece580 100644
--- a/csync/src/csync_owncloud.h
+++ b/csync/src/csync_owncloud.h
@@ -173,7 +173,7 @@ int owncloud_closedir(csync_vio_handle_t *dhandle);
int owncloud_stat(const char *uri, csync_vio_file_stat_t *buf);
int owncloud_commit(void);
char *owncloud_error_string(void);
-void owncloud_init(csync_auth_callback cb, void *userdata);
+void owncloud_init(void *userdata);
int owncloud_set_property(const char *key, void *data);
#endif /* CSYNC_OWNCLOUD_H */
diff --git a/src/owncloudcmd/owncloudcmd.cpp b/src/owncloudcmd/owncloudcmd.cpp
index b185816..a1746f9 100644
--- a/src/owncloudcmd/owncloudcmd.cpp
+++ b/src/owncloudcmd/owncloudcmd.cpp
@@ -157,7 +157,6 @@ int main(int argc, char **argv) {
account.setSslErrorHandler(sslErrorHandler);
AccountManager::instance()->setAccount(&account);
-
CSYNC *_csync_ctx;
if( csync_create( &_csync_ctx, options.source_dir.toUtf8(),
options.target_url.toUtf8()) < 0 ) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list