Example #1
0
gint plugin_init(gchar **error)
{
	gchar *rcpath;

	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, _("Fetchinfo"), error))
		return -1;

	mail_receive_hook_id = hooks_register_hook(MAIL_RECEIVE_HOOKLIST, mail_receive_hook, NULL);
	if (mail_receive_hook_id == (guint)-1) {
		/* i18n: Possible error message during plugin load */
		*error = g_strdup(_("Failed to register mail receive hook"));
		return -1;
	}

	prefs_set_default(param);
	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
	prefs_read_config(param, "Fetchinfo", rcpath, NULL);
	g_free(rcpath);

	fetchinfo_gtk_init();

	debug_print("Fetchinfo plugin loaded\n");

	return 0;
}
gint plugin_init(gchar **error)
{
  /* Version check */
  if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,9,3,0),
                           VERSION_NUMERIC, "Gnome", error))
    return -1;

  hook_address_completion = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST,
                                                my_address_completion_build_list_hook, NULL);

  if(hook_address_completion == (guint) -1) {
    *error = g_strdup("Failed to register address completion hook in the Gnome plugin");
    return -1;
  }

  hook_password = hooks_register_hook(PASSWORD_GET_HOOKLIST, &password_get_hook, NULL);
  if(hook_password == (guint) -1) {
    *error = g_strdup("Failed to register password hook in the Gnome plugin");
    return -1;
  }

  debug_print("Gnome plugin loaded\n");

  return 0;
}
Example #3
0
gint plugin_init(gchar **error)
{
	gchar *rcpath;

	hook_id = HOOK_NONE;

	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, PLUGIN_NAME, error))
		return -1;

	prefs_set_default(param);
	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
	prefs_read_config(param, "Bogofilter", rcpath, NULL);
	g_free(rcpath);

	bogofilter_gtk_init();
		
	debug_print("Bogofilter plugin loaded\n");

#ifdef USE_PTHREAD
	bogofilter_start_thread();
#endif

	if (config.process_emails) {
		bogofilter_register_hook();
	}

	procmsg_register_spam_learner(bogofilter_learn);
	procmsg_spam_set_folder(config.save_folder, bogofilter_get_spam_folder);

	return 0;
	
}
Example #4
0
gint plugin_init (gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, _("NewMail"), error))
		return -1;

	hook_id = hooks_register_hook (MAIL_POSTFILTERING_HOOKLIST, newmail_hook, NULL);
	if (hook_id == -1) {
		*error = g_strdup (_("Failed to register newmail hook"));
		return (-1);
	}

	if (!NewLog) {
		auto char *mode = truncLog ? "w" : "a";
		if (!LogName) {
			LogName = g_strconcat(getenv ("HOME"), G_DIR_SEPARATOR_S, DEFAULT_DIR,
					G_DIR_SEPARATOR_S, LOG_NAME, NULL);
		}
		if (!(NewLog = fopen (LogName, mode))) {
			debug_print ("Failed to open default log %s\n", LogName);
			/* try fallback location */
			g_free(LogName);
			LogName = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, LOG_NAME, NULL);
			if (!(NewLog = fopen (LogName, mode))) {
				char buf[BUFSIZE];

				debug_print ("Failed to open fallback log %s\n", LogName);
#if (_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE
				strerror_r(errno, buf, BUFSIZE);
				*error = g_strdup_printf(_("Could not open log file %s: %s\n"),
						LogName, buf);
#else /* use GNU version */
				*error = g_strdup_printf(_("Could not open log file %s: %s\n"),
						LogName, strerror_r(errno, buf, BUFSIZE));
#endif
				plugin_done ();
				return (-1);
			}
		}
		setbuf (NewLog, NULL);
	}

	debug_print ("Newmail plugin loaded\n"
              "Message header summaries written to %s\n", LogName);
	if (pluginDesc == NULL)
		pluginDesc = g_strdup_printf(
			_("This plugin writes a header summary to a log file for each "
			"mail received after sorting.\n\n"
			"Default is ~/Mail/NewLog\n\nCurrent log is %s"), LogName);
	return (0);
} /* plugin_init */
Example #5
0
gint plugin_init(gchar **error)
{
    if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
                              VERSION_NUMERIC, PLUGIN_NAME, error))
        return -1;

    sgpgme_init();
    prefs_gpg_init();
    sgpgme_check_create_key();
    pgp_viewer_init();
    autocompletion_init(error);

    return 0;
}
Example #6
0
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,8,1,46),
				VERSION_NUMERIC, _("vCalendar"), error))
		return -1;

	tzset();

	curl_global_init(CURL_GLOBAL_DEFAULT);
	vcalendar_init();
	connect_dbus();

	return 0;	
}
Example #7
0
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, _("TNEF Parser"), error))
		return -1;

	tnef_parser = g_new0(MimeParser, 1);
	tnef_parser->type = MIMETYPE_APPLICATION;
	tnef_parser->sub_type = "ms-tnef";
	tnef_parser->parse = tnef_parse;
	
	procmime_mimeparser_register(tnef_parser);

	return 0;
}
Example #8
0
gint plugin_init(gchar **error)
{
    gchar *rcpath;

    /* Version check */
    if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,13,2,39),
                             VERSION_NUMERIC, _("GData"), error))
        return -1;

    hook_address_completion = hooks_register_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST,
                              my_address_completion_build_list_hook, NULL);
    if(hook_address_completion == (guint) -1) {
        *error = g_strdup(_("Failed to register address completion hook in the GData plugin"));
        return -1;
    }

    hook_offline_switch = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST, my_offline_switch_hook, NULL);
    if(hook_offline_switch == (guint) -1) {
        hooks_unregister_hook(ADDDRESS_COMPLETION_BUILD_ADDRESS_LIST_HOOKLIST, hook_address_completion);
        *error = g_strdup(_("Failed to register offline switch hook in the GData plugin"));
        return -1;
    }

    /* Configuration */
    prefs_set_default(cm_gdata_param);
    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
    prefs_read_config(cm_gdata_param, "GDataPlugin", rcpath, NULL);
    g_free(rcpath);

    /* If the refresh token is still stored in config, save it to
     * password store. */
    if(cm_gdata_config.oauth2_refresh_token != NULL) {
        passwd_store_set(PWS_PLUGIN, "GData", GDATA_TOKEN_PWD_STRING,
                         cm_gdata_config.oauth2_refresh_token, TRUE);
        passwd_store_write_config();
    }

    cm_gdata_prefs_init();

    debug_print("GData plugin loaded\n");

    /* contacts cache */
    cm_gdata_load_contacts_cache_from_file();
    cm_gdata_update_contacts_update_timer();
    cm_gdata_update_contacts_cache();

    return 0;
}
Example #9
0
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
		VERSION_NUMERIC, _("ExtmailHeaderFixer"), error))
		return -1;

	mail_receive_hook_id = hooks_register_hook(MAIL_RECEIVE_HOOKLIST, mail_receive_hook, NULL);
	if (mail_receive_hook_id == (guint)-1) {
		*error = g_strdup("Failed to register mail receive hook");
		return -1;
	}

	debug_print("ExtmailHeaderFixer plugin loaded\n");

	return 0;
}
Example #10
0
gint plugin_init(gchar **error)
{
    gchar *rcpath;

    if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
                              VERSION_NUMERIC, PLUGIN_NAME, error))
        return -1;

    hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
    if (hook_id == -1) {
        *error = g_strdup(_("Failed to register mail filtering hook"));
        return -1;
    }

    prefs_set_default(param);
    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
    prefs_read_config(param, "ClamAV", rcpath, NULL);
    g_free(rcpath);

    clamav_gtk_init();

    if (config.clamav_enable) {
        debug_print("Creating socket\n");
        config.alert_ack = TRUE;
        Clamd_Stat status = clamd_prepare();
        switch (status) {
        case NO_SOCKET:
            g_warning("[init] No socket information");
            alertpanel_error(_("Init\nNo socket information.\nAntivirus disabled."));
            break;
        case NO_CONNECTION:
            g_warning("[init] Clamd does not respond to ping");
            alertpanel_warning(_("Init\nClamd does not respond to ping.\nIs clamd running?"));
            break;
        default:
            break;
        }
    }

    debug_print("Clamd plugin loaded\n");

    return 0;

}
Example #11
0
gint plugin_init(gchar** error)
{
	MainWindow *mainwin = mainwindow_get_mainwindow();

	if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,4,0,65),
				VERSION_NUMERIC, PLUGIN_NAME, error))
		return -1;

	gtk_action_group_add_actions(mainwin->action_group, archiver_main_menu,
			1, (gpointer)mainwin);
	MENUITEM_ADDUI_ID_MANAGER(mainwin->ui_manager, "/Menu/Tools", "CreateArchive", 
			  "Tools/CreateArchive", GTK_UI_MANAGER_MENUITEM,
			  main_menu_id)

	archiver_prefs_init();

	debug_print("archive plugin loaded\n");

	return 0;
}
Example #12
0
/**
 * Initialize plugin.
 *
 * @param error  For storing the returned error message.
 *
 * @return 0 if initialization succeeds, -1 on failure.
 */
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				  VERSION_NUMERIC, _("Attach warner"), error))
		return -1;

	hook_id = hooks_register_hook(COMPOSE_CHECK_BEFORE_SEND_HOOKLIST, 
				      attwarn_before_send_hook, NULL);
	
	if (hook_id == -1) {
		*error = g_strdup(_("Failed to register check before send hook"));
		return -1;
	}

	attachwarner_prefs_init();

	debug_print("Attachment warner plugin loaded\n");

	return 0;
}
Example #13
0
gint plugin_init(gchar **error)
{
	gchar *rcpath;

	hook_id = -1;

	if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
				VERSION_NUMERIC, PLUGIN_NAME, error))
		return -1;

	prefs_set_default(param);
	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
	prefs_read_config(param, "SpamAssassin", rcpath, NULL);
	g_free(rcpath);
	if (!spamassassin_check_username()) {
		*error = g_strdup(_("Failed to get username"));
		return -1;
	}
	spamassassin_gtk_init();
		
	debug_print("SpamAssassin plugin loaded\n");

	if (config.process_emails) {
		spamassassin_register_hook();
	}

	if (!config.enable || config.transport == SPAMASSASSIN_DISABLED) {
		log_warning(LOG_PROTOCOL, _("SpamAssassin plugin is loaded but disabled by its preferences.\n"));
	}
	else {
		if (config.transport == SPAMASSASSIN_TRANSPORT_TCP)
			debug_print("Enabling learner with a remote spamassassin server requires spamc/spamd 3.1.x\n");
		procmsg_register_spam_learner(spamassassin_learn);
		procmsg_spam_set_folder(config.save_folder, spamassassin_get_spam_folder);
	}

	return 0;
	
}
Example #14
0
/**
 * Initialize plugin.
 *
 * @param error  For storing the returned error message.
 *
 * @return 0 if initialization succeeds, -1 on failure.
 */
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,9,3,29),
				  VERSION_NUMERIC, _("Libravatar"), error))
		return -1;
	/* get info from headers */
	update_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST,
					     libravatar_header_update_hook,
					     NULL);
	if (update_hook_id == -1) {
		*error = g_strdup(_("Failed to register avatar header update hook"));
		return -1;
	}
	/* get image for displaying */
	render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST,
					     libravatar_image_render_hook,
					     NULL);
	if (render_hook_id == -1) {
		*error = g_strdup(_("Failed to register avatar image render hook"));
		return -1;
	}
	/* cache dir */
	if (cache_dir_init() == -1) {
		*error = g_strdup(_("Failed to create avatar image cache directory"));
		return -1;
	}
	/* preferences page */
	libravatar_prefs_init();
	/* curl library */
	curl_global_init(CURL_GLOBAL_DEFAULT);
	/* missing cache */
	if (missing_cache_init() == -1) {
		*error = g_strdup(_("Failed to load missing items cache"));
		return -1;
	}
	debug_print("Libravatar plugin loaded\n");

	return 0;
}
Example #15
0
gint plugin_init(gchar **error)
{
	if (!check_plugin_version(MAKE_NUMERIC_VERSION(3,9,3,29),
				VERSION_NUMERIC, _("QR-Avatar"), error))
		return -1;

	if ((update_hook_id = hooks_register_hook(AVATAR_HEADER_UPDATE_HOOKLIST, qr_avatar_update_hook, NULL)) == -1)
	{
		*error = g_strdup(_("Failed to register QR-Avatar update hook"));
		return -1;
	}

	if ((render_hook_id = hooks_register_hook(AVATAR_IMAGE_RENDER_HOOKLIST, qr_avatar_render_hook, NULL)) == -1)
	{
		*error = g_strdup(_("Failed to register QR-Avatar render hook"));
		return -1;
	}

	debug_print("QR-Avatar plugin loaded\n");

	return EXIT_SUCCESS;
}
Example #16
0
gint plugin_init(gchar **error)
{
  PyObject *inst_StringIO = NULL;

  /* Version check */
  if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,7,6,9), VERSION_NUMERIC, _("Python"), error))
    return -1;

  /* load hooks */
  hook_compose_create = hooks_register_hook(COMPOSE_CREATED_HOOKLIST, my_compose_create_hook, NULL);
  if(hook_compose_create == (guint)-1) {
    *error = g_strdup(_("Failed to register \"compose create hook\" in the Python plugin"));
    return -1;
  }

  /* script directories */
  if(!make_sure_directories_exist(error))
    goto err;

  /* initialize python interpreter */
  Py_Initialize();

  /* The Python C API only offers to print an exception to sys.stderr. In order to catch it
   * in a string, a StringIO object is created, to which sys.stderr can be redirected in case
   * an error occured. */
  inst_StringIO = get_StringIO_instance();

  /* initialize Claws Mail Python module */
  initclawsmail();
  if(PyErr_Occurred()) {
    *error = get_exception_information(inst_StringIO);
    goto err;
  }

  if(PyRun_SimpleString("import clawsmail") == -1) {
    *error = g_strdup("Error importing the clawsmail module");
    goto err;
  }

  /* initialize python interactive shell */
  if(!parasite_python_init(error)) {
    goto err;
  }

  /* load menu options */
  if(!python_menu_init(error)) {
    goto err;
  }

  /* problems here are not fatal */
  run_auto_script_file_if_it_exists(PYTHON_SCRIPTS_AUTO_STARTUP, NULL);

  debug_print("Python plugin loaded\n");

  return 0;

err:
  hooks_unregister_hook(COMPOSE_CREATED_HOOKLIST, hook_compose_create);
  Py_XDECREF(inst_StringIO);
  return -1;
}
Example #17
0
gint plugin_init(gchar **error)
{
  gchar *rcpath;

  /* Version check */
  /* No be able to test against new-contacts */
  if(!check_plugin_version(MAKE_NUMERIC_VERSION(3,8,1,46),
			   VERSION_NUMERIC, _("Notification"), error))
    return -1;

  /* Check if threading is enabled */
  if(!g_thread_supported()) {
    *error = g_strdup(_("The Notification plugin needs threading support."));
    return -1;
  }

  hook_f_item = hooks_register_hook(FOLDER_ITEM_UPDATE_HOOKLIST,
				    my_folder_item_update_hook, NULL);
  if(hook_f_item == (guint) -1) {
    *error = g_strdup(_("Failed to register folder item update hook in the "
			"Notification plugin"));
    return -1;
  }

  hook_f = hooks_register_hook(FOLDER_UPDATE_HOOKLIST,
			       my_folder_update_hook, NULL);
  if(hook_f == (guint) -1) {
    *error = g_strdup(_("Failed to register folder update hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    return -1;
  }


  hook_m_info = hooks_register_hook(MSGINFO_UPDATE_HOOKLIST,
				    my_msginfo_update_hook, NULL);
  if(hook_m_info == (guint) -1) {
    *error = g_strdup(_("Failed to register msginfo update hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    return -1;
  }

  hook_offline = hooks_register_hook(OFFLINE_SWITCH_HOOKLIST,
				     my_offline_switch_hook, NULL);
  if(hook_offline == (guint) -1) {
    *error = g_strdup(_("Failed to register offline switch hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
    return -1;
  }

  hook_mw_close = hooks_register_hook(MAIN_WINDOW_CLOSE,
				      my_main_window_close_hook, NULL);
  if(hook_mw_close == (guint) -1) {
    *error = g_strdup(_("Failed to register main window close hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
    hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, hook_offline);
    return -1;
  }

  hook_got_iconified = hooks_register_hook(MAIN_WINDOW_GOT_ICONIFIED,
					   my_main_window_got_iconified_hook,
					   NULL);
  if(hook_got_iconified == (guint) -1) {
    *error = g_strdup(_("Failed to register got iconified hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
    hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, hook_offline);
    hooks_unregister_hook(MAIN_WINDOW_CLOSE, hook_mw_close);
    return -1;
  }

  hook_account = hooks_register_hook(ACCOUNT_LIST_CHANGED_HOOKLIST,
				     my_account_list_changed_hook, NULL);
  if (hook_account == (guint) -1) {
    *error = g_strdup(_("Failed to register account list changed hook in the "
			"Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
    hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, hook_offline);
    hooks_unregister_hook(MAIN_WINDOW_CLOSE, hook_mw_close);
    hooks_unregister_hook(MAIN_WINDOW_GOT_ICONIFIED, hook_got_iconified);
    return -1;
  }

  hook_theme_changed = hooks_register_hook(THEME_CHANGED_HOOKLIST, my_update_theme_hook, NULL);
  if(hook_theme_changed == (guint)-1) {
    *error = g_strdup(_("Failed to register theme change hook int the "
      "Notification plugin"));
    hooks_unregister_hook(FOLDER_ITEM_UPDATE_HOOKLIST, hook_f_item);
    hooks_unregister_hook(FOLDER_UPDATE_HOOKLIST, hook_f);
    hooks_unregister_hook(MSGINFO_UPDATE_HOOKLIST, hook_m_info);
    hooks_unregister_hook(OFFLINE_SWITCH_HOOKLIST, hook_offline);
    hooks_unregister_hook(MAIN_WINDOW_CLOSE, hook_mw_close);
    hooks_unregister_hook(MAIN_WINDOW_GOT_ICONIFIED, hook_got_iconified);
    hooks_unregister_hook(ACCOUNT_LIST_CHANGED_HOOKLIST, hook_account);
    return -1;
  }

  /* Configuration */
  prefs_set_default(notify_param);
  rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
  prefs_read_config(notify_param, "NotificationPlugin", rcpath, NULL);
  g_free(rcpath);

  /* Folder specific stuff */
  notification_foldercheck_read_array();

  notification_notified_hash_startup_init();

  notify_gtk_init();

#ifdef NOTIFICATION_BANNER
  notification_update_banner();
#endif
#ifdef NOTIFICATION_LCDPROC
  notification_lcdproc_connect();
#endif
#ifdef NOTIFICATION_TRAYICON
  if(notify_config.trayicon_enabled &&
		 notify_config.trayicon_hide_at_startup && claws_is_starting()) {
    MainWindow *mainwin = mainwindow_get_mainwindow();

		g_idle_add(trayicon_startup_idle,NULL);
    if(mainwin && gtk_widget_get_visible(GTK_WIDGET(mainwin->window)))
      main_window_hide(mainwin);
    main_set_show_at_startup(FALSE);
  }
#endif
  my_account_list_changed_hook(NULL,NULL);

  if(notify_config.urgency_hint_new || notify_config.urgency_hint_unread)
	notification_update_msg_counts(NULL);

#ifdef NOTIFICATION_HOTKEYS
  notification_hotkeys_update_bindings();
#endif

  debug_print("Notification plugin loaded\n");

  return 0;
}