#include <imap.h>
#include <sys/types.h>
#include <sys/stat.h>
+#if (defined (__NetBSD__) || defined (__FreeBSD__))
+#include <sys/socket.h>
+#endif
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/wait.h>
return result.error;
}
+
+struct capa_param {
+ mailimap * imap;
+};
+
+struct capa_result {
+ int error;
+ struct mailimap_capability_data *caps;
+};
+
+static void capability_run(struct etpan_thread_op * op)
+{
+ int r;
+ struct capa_param * param;
+ struct capa_result * result;
+ struct mailimap_capability_data *caps;
+
+ param = op->param;
+ result = op->result;
+
+ r = mailimap_capability(param->imap, &caps);
+
+ result->error = r;
+ result->caps = caps;
+}
+
+
+struct mailimap_capability_data * imap_threaded_capability(Folder *folder)
+{
+ struct capa_param param;
+ struct capa_result result;
+ mailimap *imap;
+
+ imap = get_imap(folder);
+
+ param.imap = imap;
+
+ threaded_run(folder, ¶m, &result, capability_run);
+
+ debug_print("capa ok\n");
+
+ return result.caps;
+
+}
struct disconnect_param {
mailimap * imap;
mailimap * imap;
const char * login;
const char * password;
+ const char * type;
};
struct login_result {
old_debug = mailstream_debug;
mailstream_debug = 0;
#endif
-
- r = mailimap_login(param->imap,
+ if (!strcmp(param->type, "LOGIN"))
+ r = mailimap_login(param->imap,
param->login, param->password);
-
+ else
+ r = mailimap_authenticate(param->imap,
+ param->type, NULL, NULL, NULL,
+ param->login, param->login,
+ param->password, NULL);
#ifdef DISABLE_LOG_DURING_LOGIN
mailstream_debug = old_debug;
#endif
}
int imap_threaded_login(Folder * folder,
- const char * login, const char * password)
+ const char * login, const char * password,
+ const char * type)
{
struct login_param param;
struct login_result result;
param.imap = get_imap(folder);
param.login = login;
param.password = password;
-
+ param.type = type;
+
threaded_run(folder, ¶m, &result, login_run);
debug_print("imap login - end\n");
r = fclose(f);
if (r == EOF) {
- unlink(param->filename);
+ g_unlink(param->filename);
goto close;
}
goto free;
close:
close(fd);
unlink:
- unlink(param->filename);
+ g_unlink(param->filename);
free:
if (mmap_string_unref(content) != 0)
}
+#define ENV_BUFFER_SIZE 512
static void do_exec_command(int fd, const char * command,
const char * servername, uint16_t port)
{
int i, maxopen;
-
+#ifdef SOLARIS
+ char env_buffer[ENV_BUFFER_SIZE];
+#endif
+
if (fork() > 0) {
/* Fork again to become a child of init rather than
the etpan client. */
exit(0);
}
+#ifdef SOLARIS
+ if (servername)
+ snprintf(env_buffer, ENV_BUFFER_SIZE,
+ "ETPANSERVER=%s", servername);
+ else
+ snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANSERVER=");
+ putenv(env_buffer);
+#else
if (servername)
setenv("ETPANSERVER", servername, 1);
else
unsetenv("ETPANSERVER");
+#endif
+#ifdef SOLARIS
+ if (port)
+ snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANPORT=%d", port);
+ else
+ snprintf(env_buffer, ENV_BUFFER_SIZE, "ETPANPORT=");
+ putenv(env_buffer);
+#else
if (port) {
char porttext[20];
-
+
snprintf(porttext, sizeof(porttext), "%d", port);
setenv("ETPANPORT", porttext, 1);
}
else {
unsetenv("ETPANPORT");
}
-
+#endif
+
/* Not a lot we can do if there's an error other than bail. */
if (dup2(fd, 0) == -1)
exit(1);