Commit 67b66aca authored by Arturo Espinosa's avatar Arturo Espinosa

Mailcheck applet fixes: you can change the theme again. Panel and applets



Mailcheck applet fixes: you can change the theme again.
Panel and applets now got cookies.  This is all transparent
to the applet writer.
parent aaa63982
1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mailcheck/mailcheck.c (create_mail_widgets): Added refs
(load_new_pixmap_callback): Call mail check timeout.
Thu Apr 23 02:24:16 1998 George Lebl <jirka@5z.com>
* cdplayer/cdplayer.c: using SHADOW_IN instead of ETCHED_IN
......
1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mailcheck/mailcheck.c (create_mail_widgets): Added refs
(load_new_pixmap_callback): Call mail check timeout.
Thu Apr 23 02:24:16 1998 George Lebl <jirka@5z.com>
* cdplayer/cdplayer.c: using SHADOW_IN instead of ETCHED_IN
......
1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mailcheck/mailcheck.c (create_mail_widgets): Added refs
(load_new_pixmap_callback): Call mail check timeout.
Thu Apr 23 02:24:16 1998 George Lebl <jirka@5z.com>
* cdplayer/cdplayer.c: using SHADOW_IN instead of ETCHED_IN
......
1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mailcheck/mailcheck.c (create_mail_widgets): Added refs
(load_new_pixmap_callback): Call mail check timeout.
Thu Apr 23 02:24:16 1998 George Lebl <jirka@5z.com>
* cdplayer/cdplayer.c: using SHADOW_IN instead of ETCHED_IN
......
1998-04-24 Miguel de Icaza <miguel@nuclecu.unam.mx>
* mailcheck/mailcheck.c (create_mail_widgets): Added refs
(load_new_pixmap_callback): Call mail check timeout.
Thu Apr 23 02:24:16 1998 George Lebl <jirka@5z.com>
* cdplayer/cdplayer.c: using SHADOW_IN instead of ETCHED_IN
......
......@@ -9,6 +9,9 @@
#include "mico-parse.h"
#include <fcntl.h>
#define CHECK_COOKIE() if (strcmp (cookie, ccookie)) return;
#define CHECK_COOKIE_V(x) if (strcmp (cookie, ccookie)) return x;
#define APPLET_EVENT_MASK (GDK_BUTTON_PRESS_MASK | \
GDK_BUTTON_RELEASE_MASK | \
GDK_POINTER_MOTION_MASK | \
......@@ -37,6 +40,8 @@ GHashTable *applet_callbacks=NULL;
CORBA::ORB_ptr orb_ptr;
CORBA::BOA_ptr boa_ptr;
char *cookie;
/*every applet must implement these*/
BEGIN_GNOME_DECLS
void change_orient(int applet_id, int orient);
......@@ -47,19 +52,23 @@ class Applet_impl : virtual public GNOME::Applet_skel {
GtkWidget *the_widget;
public:
Applet_impl (GtkWidget *widget) { the_widget = widget; };
void change_orient (CORBA::Short applet_id, CORBA::Short orient) {
void change_orient (const char *ccookie, CORBA::Short applet_id, CORBA::Short orient) {
::change_orient(applet_id,orient);
}
CORBA::Short session_save (CORBA::Short applet_id,
CORBA::Short session_save (const char *ccookie,
CORBA::Short applet_id,
const char *cfgpath,
const char *globcfgpath) {
CHECK_COOKIE_V (0);
return ::session_save(applet_id,cfgpath,globcfgpath);
}
void do_callback (CORBA::Short applet_id,
void do_callback (const char *ccookie,
CORBA::Short applet_id,
const char *callback_name)
{
GList *list;
CHECK_COOKIE ();
if(!applet_callbacks)
return;
......@@ -88,6 +97,8 @@ gnome_panel_applet_init_corba (void)
if (hostname [0] == 0)
strcpy (hostname, "unknown-host");
cookie = gnome_config_private_get_string ("/panel/Secret/cookie=");
/*do a 20 second timeout until we get the iior*/
for(i=0;i<20;i++) {
name = g_copy_strings ("/CORBA-servers/Panel-", hostname,
......@@ -173,7 +184,7 @@ gnome_panel_applet_register_callback(int applet_id,
g_hash_table_insert(applet_callbacks,name,list);
/*register the callback with the panel*/
panel_client->applet_add_callback(applet_id,name,menutext);
panel_client->applet_add_callback(cookie, applet_id,name,menutext);
}
/*catch events relevant to the panel and notify the panel*/
......@@ -187,25 +198,25 @@ applet_event(GtkWidget *widget, GdkEvent *event, gpointer data)
case GDK_BUTTON_PRESS:
bevent = (GdkEventButton *) event;
if(bevent->button == 2 && currently_dragged_id==-1) {
panel_client->applet_drag_start(ourid);
panel_client->applet_drag_start(cookie,ourid);
currently_dragged_id = ourid;
move_grab_add(widget);
return TRUE;
} else if(currently_dragged_id > -1) {
panel_client->applet_drag_stop(ourid);
panel_client->applet_drag_stop(cookie,ourid);
currently_dragged_id = -1;
move_grab_remove(widget);
return TRUE;
} else if(bevent->button == 3) {
gdk_pointer_ungrab(GDK_CURRENT_TIME);
gtk_grab_remove(widget);
panel_client->applet_show_menu(ourid);
panel_client->applet_show_menu(cookie, ourid);
return TRUE;
}
break;
case GDK_BUTTON_RELEASE:
if(currently_dragged_id > -1) {
panel_client->applet_drag_stop(ourid);
panel_client->applet_drag_stop(cookie, ourid);
currently_dragged_id = -1;
move_grab_remove(widget);
return TRUE;
......@@ -296,7 +307,7 @@ gnome_panel_applet_request_id (char *path,
for(i=0;i<20;i++) {
try {
/*reserve a spot and get an id for this applet*/
*applet_id = panel_client->applet_request_id(path,cfg,
*applet_id = panel_client->applet_request_id(cookie,path,cfg,
globcfg,
wid);
} catch (...) {
......@@ -356,7 +367,7 @@ gnome_panel_applet_register (GtkWidget *widget, int applet_id)
ior = orb_ptr->object_to_string (applet);
panel_client->applet_register(ior,applet_id);
panel_client->applet_register(cookie, ior,applet_id);
bind_top_applet_events(widget,applet_id);
......@@ -366,7 +377,7 @@ gnome_panel_applet_register (GtkWidget *widget, int applet_id)
char *
gnome_panel_applet_abort_id (gint applet_id)
{
panel_client->applet_abort_id(applet_id);
panel_client->applet_abort_id(cookie, applet_id);
return 0;
}
......@@ -374,7 +385,7 @@ gnome_panel_applet_abort_id (gint applet_id)
char *
gnome_panel_applet_add_tooltip (gint applet_id, char *tooltip)
{
panel_client->applet_add_tooltip(applet_id,tooltip);
panel_client->applet_add_tooltip(cookie, applet_id,tooltip);
return 0;
}
......@@ -382,7 +393,7 @@ gnome_panel_applet_add_tooltip (gint applet_id, char *tooltip)
char *
gnome_panel_applet_remove_tooltip (gint applet_id)
{
panel_client->applet_remove_tooltip(applet_id);
panel_client->applet_remove_tooltip(cookie, applet_id);
return 0;
}
......@@ -396,7 +407,7 @@ gnome_panel_applet_request_glob_cfg (char **globcfgpath)
g_return_val_if_fail(globcfgpath!=NULL,0);
panel_client->applet_request_glob_cfg(globcfg);
panel_client->applet_request_glob_cfg(cookie, globcfg);
if(globcfg!= NULL) {
*globcfgpath = g_strdup(globcfg);
......@@ -414,7 +425,7 @@ gnome_panel_quit (void)
{
char *result;
panel_client->quit ();
panel_client->quit (cookie);
return 0;
}
......
......@@ -4,76 +4,20 @@
#include <stdio.h>
#include <sys/stat.h>
char *cookie_file, *cookie_dir;
#define COOKIE_SIZE 12
static void
check_dir_permissions (char *s)
{
struct stat sb;
if (stat (s, &sb) == -1){
printf ("Can not stat %s\n", s);
exit (1);
}
if (!S_ISDIR (sb.st_mode)){
printf ("%s is not a directory\n", s);
exit (1);
}
if (chmod (s, 0700) != 0){
printf ("%s can not set permissions to %s\n", s);
exit (1);
}
}
static void
create_cookie ()
char *
create_cookie (void)
{
FILE *f;
int i;
f = fopen (cookie_file, "w");
if (f == NULL){
printf ("Could not create cookie file %s\n", cookie_file);
exit (1);
}
char *cookie, *p;
srandom (time (NULL));
for (i = 0; i < 80; i++){
p = cookie = g_malloc (COOKIE_SIZE + 1);
for (i = 0; i < COOKIE_SIZE; i++){
int v = (random () % 50) + 'A';
fputc (v, f);
}
fclose (f);
}
char *
compute_cookie ()
{
FILE *f;
static char buffer [90];
f = fopen (cookie_file, "w");
if (f == NULL){
printf ("Could not open cookie file\n", cookie_file);
exit (1);
*p++ = v;
}
fgets (buffer, 80, f);
fclose (f);
buffer [80] = 0;
return buffer;
}
void
poor_security_cookie_init (void)
{
char buffer [40];
srandom (time (NULL));
snprintf (buffer,40, "%d-%d", getpid (), (int)random());
cookie_dir = g_copy_strings ("/tmp/.panel-", buffer, NULL);
mkdir (cookie_dir, 0700);
check_dir_permissions (cookie_dir);
cookie_file = g_concat_dir_and_file (cookie_dir, "cookie");
return cookie;
}
#
# The cookie is an extremely *BAD* hack that we have implemented
# for security reasons for *NOW*
#
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that
contacts the Panel */
short applet_request_id(in string path,
short applet_request_id(in string cookie,
in string path,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
void applet_register(in string ior, in short applet_id);
void applet_abort_id(in short applet_id);
void applet_request_glob_cfg(out string globcfgpath);
void applet_remove_from_panel (in short applet_id);
short applet_get_panel (in short applet_id);
short applet_get_pos (in short applet_id);
void applet_show_menu (in short applet_id);
void applet_drag_start (in short applet_id);
void applet_drag_stop (in short applet_id);
void applet_add_callback (in short applet_id,
void applet_register(in string cookie, in string ior, in short applet_id);
void applet_abort_id(in string cookie, in short applet_id);
void applet_request_glob_cfg(in string cookie, out string globcfgpath);
void applet_remove_from_panel (in string cookie, in short applet_id);
short applet_get_panel (in string cookie, in short applet_id);
short applet_get_pos (in string cookie, in short applet_id);
void applet_show_menu (in string cookie, in short applet_id);
void applet_drag_start (in string cookie, in short applet_id);
void applet_drag_stop (in string cookie, in short applet_id);
void applet_add_callback (in string cookie,
in short applet_id,
in string callback_name,
in string menuitem_text);
void applet_add_tooltip (in short applet_id, in string tooltip);
void applet_remove_tooltip (in short applet_id);
void quit();
void applet_add_tooltip (in string cookie, in short applet_id, in string tooltip);
void applet_remove_tooltip (in string cookie, in short applet_id);
void quit(in string cookie);
};
interface Applet {
void change_orient (in short applet_id, in short orient);
void do_callback (in short applet_id, in string callback_name);
short session_save (in short applet_id,
void change_orient (in string cookie, in short applet_id, in short orient);
void do_callback (in string cookie, in short applet_id, in string callback_name);
short session_save (in string cookie,
in short applet_id,
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string path);
void restart_all_launchers ();
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
......@@ -12,18 +12,24 @@
extern CORBA::ORB_ptr orb_ptr;
extern CORBA::BOA_ptr boa_ptr;
char *cookie;
/*every launcher must implement these*/
BEGIN_GNOME_DECLS
void start_new_launcher(const char *path);
void restart_all_launchers(void);
END_GNOME_DECLS
#define CHECK_COOKIE() if (strcmp (cookie, ccookie)) return;
class Launcher_impl : virtual public GNOME::Launcher_skel {
public:
void start_new_launcher (const char *path) {
void start_new_launcher (const char *ccookie, const char *path) {
CHECK_COOKIE ();
::start_new_launcher(path);
}
void restart_all_launchers (void) {
void restart_all_launchers (const char *ccookie) {
CHECK_COOKIE ();
::restart_all_launchers ();
}
};
......@@ -35,6 +41,7 @@ launcher_corba_gtk_main (char *str)
char hostname [4096];
char *name;
cookie = gnome_config_private_get_string ("/panel/Secret/cookie=");
gethostname (hostname, sizeof (hostname));
if (hostname [0] == 0)
strcpy (hostname, "unknown-host");
......
......@@ -71,6 +71,9 @@ GList *load_queue=NULL;
/* True if parsing determined that all the work is already done. */
int just_exit = 0;
/* The security cookie */
char *cookie;
/* These are the arguments that our application supports. */
static struct argp_option arguments[] =
{
......@@ -885,6 +888,10 @@ main(int argc, char **argv)
if (just_exit)
return 0;
/* Setup the cookie */
cookie = create_cookie ();
gnome_config_private_set_string ("/panel/Secret/cookie", cookie);
#ifdef USE_INTERNAL_LAUNCHER
launcher_pid=fork();
......
......@@ -13,9 +13,13 @@
* screen.
* */
#define CHECK_COOKIE() if (strcmp (cookie, ccookie)) return;
#define CHECK_COOKIE_V(x) if (strcmp (cookie, ccookie)) return x;
class Panel_impl : virtual public GNOME::Panel_skel {
public:
CORBA::Short applet_request_id (const char *path,
CORBA::Short applet_request_id (const char *ccookie,
const char *path,
char *&cfgpath,
char *&globcfgpath,
CORBA::ULong &wid) {
......@@ -24,6 +28,7 @@ public:
int applet_id;
guint32 winid;
CHECK_COOKIE_V (0);
applet_id = ::applet_request_id (path,&cfg,&globcfg,&winid);
wid = winid;
......@@ -39,15 +44,18 @@ public:
globcfgpath = CORBA::string_dup("");
return applet_id;
}
void applet_register (const char *ior, CORBA::Short applet_id) {
void applet_register (const char *ccookie, const char *ior, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_register(ior, applet_id);
}
void applet_abort_id (CORBA::Short applet_id) {
void applet_abort_id (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_abort_id (applet_id);
}
void applet_request_glob_cfg (char *&globcfgpath) {
void applet_request_glob_cfg (const char *ccookie, char *&globcfgpath) {
char *globcfg=NULL;
CHECK_COOKIE ();
::applet_request_glob_cfg (&globcfg);
if(globcfg) {
globcfgpath = CORBA::string_dup(globcfg);
......@@ -55,38 +63,49 @@ public:
} else
globcfgpath = CORBA::string_dup("");
}
CORBA::Short applet_get_panel (CORBA::Short applet_id) {
CORBA::Short applet_get_panel (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE_V (0);
return ::applet_get_panel (applet_id);
}
CORBA::Short applet_get_pos (CORBA::Short applet_id) {
CORBA::Short applet_get_pos (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE_V (0);
return ::applet_get_pos (applet_id);
}
void applet_show_menu (CORBA::Short applet_id) {
void applet_show_menu (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_show_menu (applet_id);
}
void applet_drag_start (CORBA::Short applet_id) {
void applet_drag_start (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_drag_start (applet_id);
}
void applet_drag_stop (CORBA::Short applet_id) {
void applet_drag_stop (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_drag_stop (applet_id);
}
void applet_remove_from_panel (CORBA::Short applet_id) {
applet_remove_from_panel(applet_id);
void applet_remove_from_panel (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
applet_remove_from_panel(cookie, applet_id);
}
void applet_add_callback (CORBA::Short applet_id,
void applet_add_callback (const char *ccookie,
CORBA::Short applet_id,
const char *callback_name,
const char *menuitem_text) {
CHECK_COOKIE ();
::applet_add_callback(applet_id,
(char *)callback_name,
(char *)menuitem_text);
}
void applet_add_tooltip (CORBA::Short applet_id, const char *tooltip) {
void applet_add_tooltip (const char *ccookie, CORBA::Short applet_id, const char *tooltip) {
CHECK_COOKIE ();
::applet_set_tooltip(applet_id,tooltip);
}
void applet_remove_tooltip (CORBA::Short applet_id) {
void applet_remove_tooltip (const char *ccookie, CORBA::Short applet_id) {
CHECK_COOKIE ();
::applet_set_tooltip(applet_id,NULL);
}
void quit(void) {
void quit(const char *ccookie) {
CHECK_COOKIE ();
::panel_quit();
}
};
......@@ -161,7 +180,7 @@ panel_corba_call_launcher(const char *path)
GNOME::Launcher_var launcher_client = GNOME::Launcher::_narrow (obj);
try {
launcher_client->start_new_launcher(path);
launcher_client->start_new_launcher(cookie, path);
} catch( ... ) {
return FALSE;
}
......@@ -193,7 +212,7 @@ panel_corba_restart_launchers(void)
GNOME::Launcher_var launcher_client = GNOME::Launcher::_narrow (obj);
try {
launcher_client->restart_all_launchers();
launcher_client->restart_all_launchers(cookie);
} catch( ... ) {
return FALSE;
}
......@@ -210,7 +229,7 @@ send_applet_session_save (const char *ior, int applet_id, const char *cfgpath,
GNOME::Applet_var applet = GNOME::Applet::_narrow (obj);
/* Now, use corba to invoke the routine in the panel */
return applet->session_save(applet_id,cfgpath,globcfgpath);
return applet->session_save(cookie, applet_id,cfgpath,globcfgpath);
}
void
......@@ -221,7 +240,7 @@ send_applet_change_orient (const char *ior, int applet_id, int orient)
GNOME::Applet_var applet = GNOME::Applet::_narrow (obj);
/* Now, use corba to invoke the routine in the panel */
applet->change_orient(applet_id,orient);
applet->change_orient(cookie,applet_id,orient);
}
void
......@@ -232,5 +251,5 @@ send_applet_do_callback (const char *ior, int applet_id, char *callback_name)
GNOME::Applet_var applet = GNOME::Applet::_narrow (obj);
/* Now, use corba to invoke the routine in the panel */
applet->do_callback(applet_id, callback_name);
applet->do_callback(cookie,applet_id, callback_name);
}
......@@ -126,6 +126,7 @@ void applet_add_callback(gint applet_id,
void applet_set_tooltip(gint applet_id, const char *tooltip);
void applet_remove_from_panel(gint applet_id);
extern char *cookie;
/*this is in main.c*/
void load_applet(char *id, char *params, int pos, int panel, char *cfgpath);
......
#
# The cookie is an extremely *BAD* hack that we have implemented
# for security reasons for *NOW*
#
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that
contacts the Panel */
short applet_request_id(in string path,
short applet_request_id(in string cookie,
in string path,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
void applet_register(in string ior, in short applet_id);
void applet_abort_id(in short applet_id);
void applet_request_glob_cfg(out string globcfgpath);
void applet_remove_from_panel (in short applet_id);
short applet_get_panel (in short applet_id);
short applet_get_pos (in short applet_id);
void applet_show_menu (in short applet_id);
void applet_drag_start (in short applet_id);
void applet_drag_stop (in short applet_id);
void applet_add_callback (in short applet_id,
void applet_register(in string cookie, in string ior, in short applet_id);
void applet_abort_id(in string cookie, in short applet_id);
void applet_request_glob_cfg(in string cookie, out string globcfgpath);
void applet_remove_from_panel (in string cookie, in short applet_id);
short applet_get_panel (in string cookie, in short applet_id);
short applet_get_pos (in string cookie, in short applet_id);
void applet_show_menu (in string cookie, in short applet_id);
void applet_drag_start (in string cookie, in short applet_id);
void applet_drag_stop (in string cookie, in short applet_id);
void applet_add_callback (in string cookie,
in short applet_id,
in string callback_name,
in string menuitem_text);
void applet_add_tooltip (in short applet_id, in string tooltip);
void applet_remove_tooltip (in short applet_id);
void quit();
void applet_add_tooltip (in string cookie, in short applet_id, in string tooltip);
void applet_remove_tooltip (in string cookie, in short applet_id);
void quit(in string cookie);
};
interface Applet {
void change_orient (in short applet_id, in short orient);
void do_callback (in short applet_id, in string callback_name);
short session_save (in short applet_id,
void change_orient (in string cookie, in short applet_id, in short orient);
void do_callback (in string cookie, in short applet_id, in string callback_name);
short session_save (in string cookie,
in short applet_id,
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string path);
void restart_all_launchers ();
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
#
# The cookie is an extremely *BAD* hack that we have implemented
# for security reasons for *NOW*
#
module GNOME {
interface Panel {
/* Sends the object identifier for the Applet server that
contacts the Panel */
short applet_request_id(in string path,
short applet_request_id(in string cookie,
in string path,
out string cfgpath,
out string globcfgpath,
out unsigned long wid);
void applet_register(in string ior, in short applet_id);
void applet_abort_id(in short applet_id);
void applet_request_glob_cfg(out string globcfgpath);
void applet_remove_from_panel (in short applet_id);
short applet_get_panel (in short applet_id);
short applet_get_pos (in short applet_id);
void applet_show_menu (in short applet_id);
void applet_drag_start (in short applet_id);
void applet_drag_stop (in short applet_id);
void applet_add_callback (in short applet_id,
void applet_register(in string cookie, in string ior, in short applet_id);
void applet_abort_id(in string cookie, in short applet_id);
void applet_request_glob_cfg(in string cookie, out string globcfgpath);
void applet_remove_from_panel (in string cookie, in short applet_id);
short applet_get_panel (in string cookie, in short applet_id);
short applet_get_pos (in string cookie, in short applet_id);
void applet_show_menu (in string cookie, in short applet_id);
void applet_drag_start (in string cookie, in short applet_id);
void applet_drag_stop (in string cookie, in short applet_id);
void applet_add_callback (in string cookie,
in short applet_id,
in string callback_name,
in string menuitem_text);
void applet_add_tooltip (in short applet_id, in string tooltip);
void applet_remove_tooltip (in short applet_id);
void quit();
void applet_add_tooltip (in string cookie, in short applet_id, in string tooltip);
void applet_remove_tooltip (in string cookie, in short applet_id);
void quit(in string cookie);
};
interface Applet {
void change_orient (in short applet_id, in short orient);
void do_callback (in short applet_id, in string callback_name);
short session_save (in short applet_id,
void change_orient (in string cookie, in short applet_id, in short orient);
void do_callback (in string cookie, in short applet_id, in string callback_name);
short session_save (in string cookie,
in short applet_id,
in string cfgpath,
in string globcfgpath);
};
interface Launcher {
void start_new_launcher (in string path);
void restart_all_launchers ();
void start_new_launcher (in string cookie, in string path);
void restart_all_launchers (in string cookie);
};
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment