summaryrefslogtreecommitdiff
path: root/rhimport
diff options
context:
space:
mode:
authorChristian Pointner <equinox@helsinki.at>2010-02-23 14:31:51 (GMT)
committerChristian Pointner <equinox@helsinki.at>2010-02-23 14:31:51 (GMT)
commitdf6aa6819f9ad30395682f7a257926beca0dfcf3 (patch)
treee5cf18dee01f5f96a5e74a559698172c96d4c520 /rhimport
parent0784f649410c1483886c0e4a0d805720fc408da9 (diff)
reenabled db stuff
moved to new gui with mode selector
Diffstat (limited to 'rhimport')
-rwxr-xr-xrhimport135
1 files changed, 79 insertions, 56 deletions
diff --git a/rhimport b/rhimport
index 82823f6..ee1f552 100755
--- a/rhimport
+++ b/rhimport
@@ -65,28 +65,25 @@ EOF
my $user = $ENV{'USER'};
$user or die "Username not found in environment";
-# my $dbh = DBI->connect( "DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr";
-# my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH from USER_PERMS, DROPBOXES where USER_PERMS.USER_NAME='$user' and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME;};
-# my $sth = $dbh->prepare($sql);
-# $sth->execute();
+my $dbh = DBI->connect( "DBI:mysql:$DB:$DBHOST","$DBUSER","$DBPW") or die "Database Error: $DBI::errstr";
+my $sql = qq{select USER_PERMS.GROUP_NAME,DROPBOXES.PATH from USER_PERMS, DROPBOXES where USER_PERMS.USER_NAME='$user' and DROPBOXES.GROUP_NAME=USER_PERMS.GROUP_NAME;};
+my $sth = $dbh->prepare($sql);
+$sth->execute();
my @allowed_dbs;
-push @allowed_dbs, { 'GROUP' => "groupa", 'PATH' => "/programm/dropboxA/" };
-push @allowed_dbs, { 'GROUP' => "groupb", 'PATH' => "/programm/dropboxB/" };
-push @allowed_dbs, { 'GROUP' => "groupc", 'PATH' => "/programm/dropboxC/" };
-# while(my ($group, $path) = $sth->fetchrow_array()) {
-# $path =~ s/\/\*$//;
-# my $perm = {};
-# $perm->{'GROUP'} = $group;
-# $perm->{'PATH'} = $path;
-# push @allowed_dbs, $perm;
-# }
-# $sth->finish();
+while(my ($group, $path) = $sth->fetchrow_array()) {
+ $path =~ s/\/\*$//;
+ my $perm = {};
+ $perm->{'GROUP'} = $group;
+ $perm->{'PATH'} = $path;
+ push @allowed_dbs, $perm;
+}
+$sth->finish();
if($LISTALLOWED) {
for my $href ( @allowed_dbs ) {
print "$href->{'PATH'}\n";
}
-# $dbh->disconnect();
+ $dbh->disconnect();
exit 0;
}
@@ -95,56 +92,48 @@ if($LISTALLOWED) {
my $guixml;
-if(!$FILE && !$DROPBOX) {
- Gtk2->init;
-
- $guixml = Gtk2::GladeXML->new('rhimport.glade');
- $guixml or die "can't load glade xml file";
- require gui_callbacks;
- $guixml->signal_autoconnect_from_package('gui_callbacks');
-
- my $model = Gtk2::ListStore->new('Glib::String');
- for my $href ( @allowed_dbs ) {
- $model->set ($model->append, 0, $href->{'PATH'});
+sub set_mode_playlist_gui()
+{
+ if(!$guixml) {
+ print STDERR "no GUI definition found!\n";
+ exit 0;
}
- my $co_dropbox = $guixml->get_widget('co_dropbox');
- $co_dropbox->set_model($model);
- my $renderer = Gtk2::CellRendererText->new;
- $co_dropbox->pack_start($renderer, 1);
- $co_dropbox->add_attribute($renderer, text => 0);
- $co_dropbox->set_active(0);
-
- my $appwin = $guixml->get_widget('appwin');
- $appwin or die "can't find Main Window";
- $appwin->resize(800,600);
- $appwin->show;
- Gtk2->main;
-# $dbh->disconnect();
- exit 0;
+ $POOL = 1;
+ my $l_mode = $guixml->get_widget('l_mode');
+ $l_mode->set_label("<b>Musik Pool</b>");
+ my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ $l_file_playlist->set_label("<b>Playlist</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*.m3u");
+ my $filechooser = $guixml->get_widget('filechooser');
+ $filechooser->set_filter($filter);
}
-sub change_pool_gui()
+sub set_mode_file_gui()
{
if(!$guixml) {
print STDERR "no GUI definition found!\n";
exit 0;
}
-
+
+ $POOL = 0;
+ my $l_mode = $guixml->get_widget('l_mode');
+ $l_mode->set_label("<b>Sendung</b>");
my $l_file_playlist = $guixml->get_widget('l_file_playlist');
+ $l_file_playlist->set_label("<b>Datei</b>");
+ my $filter = Gtk2::FileFilter->new;
+ $filter->add_pattern("*");
my $filechooser = $guixml->get_widget('filechooser');
+ $filechooser->set_filter($filter);
+}
- my $cb_pool = $guixml->get_widget('cb_pool');
- if($cb_pool->get_active) {
- $l_file_playlist->set_label("<b>Playlist</b>");
- my $filter = Gtk2::FileFilter->new;
- $filter->add_pattern("*.m3u");
- $filechooser->set_filter($filter);
+sub toggle_mode_gui()
+{
+ if($POOL) {
+ set_mode_file_gui();
} else {
- $l_file_playlist->set_label("<b>File</b>");
- my $filter = Gtk2::FileFilter->new;
- $filter->add_pattern("*");
- $filechooser->set_filter($filter);
+ set_mode_playlist_gui();
}
}
@@ -170,9 +159,8 @@ sub start_import_gui()
$l_status->set_label("importing from $file");
- my $cb_pool = $guixml->get_widget('cb_pool');
my $ret;
- if($cb_pool->get_active) {
+ if($POOL) {
$ret = rhimport::import_playlist($file, $dropbox);
} else {
$ret = rhimport::import_file($file, $dropbox);
@@ -181,6 +169,41 @@ sub start_import_gui()
return $ret;
}
+if(!$FILE && !$DROPBOX) {
+ Gtk2->init;
+
+ $guixml = Gtk2::GladeXML->new('rhimport.glade');
+ $guixml or die "can't load glade xml file";
+ require gui_callbacks;
+ $guixml->signal_autoconnect_from_package('gui_callbacks');
+
+ my $model = Gtk2::ListStore->new('Glib::String');
+ for my $href ( @allowed_dbs ) {
+ $model->set ($model->append, 0, $href->{'PATH'});
+ }
+ my $co_dropbox = $guixml->get_widget('co_dropbox');
+ $co_dropbox->set_model($model);
+ my $renderer = Gtk2::CellRendererText->new;
+ $co_dropbox->pack_start($renderer, 1);
+ $co_dropbox->add_attribute($renderer, text => 0);
+ $co_dropbox->set_active(0);
+
+ if($POOL) {
+ set_mode_playlist_gui();
+ } else {
+ set_mode_file_gui();
+ }
+
+ my $appwin = $guixml->get_widget('appwin');
+ $appwin or die "can't find Main Window";
+ $appwin->resize(800,600);
+ $appwin->show;
+
+ Gtk2->main;
+ $dbh->disconnect();
+ exit 0;
+}
+
###########################################
## command line mode
@@ -198,5 +221,5 @@ if($POOL) {
$ret = rhimport::import_file($FILE, $DROPBOX);
}
-# $dbh->disconnect();
+$dbh->disconnect();
exit $ret;