]> git.sur5r.net Git - bacula/bacula/commitdiff
More bat implementation
authorKern Sibbald <kern@sibbald.com>
Tue, 6 Mar 2007 13:52:48 +0000 (13:52 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 6 Mar 2007 13:52:48 +0000 (13:52 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@4322 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/migrate.c
bacula/src/dird/ua_tree.c
bacula/src/qt-console/restore/restore.cpp
bacula/src/qt-console/restore/restore.h
bacula/src/qt-console/restore/restore.ui

index 0165f7153d428c66f67d55baa231dd7366beba29..f6b369d5a47a71932d20a53ef3472fe31630d93b 100644 (file)
@@ -783,8 +783,10 @@ static int get_job_to_migrate(JCR *jcr)
       Jmsg(jcr, M_INFO, 0, _("No JobIds found to migrate.\n"));
       goto ok_out;
    }
-   Jmsg(jcr, M_INFO, 0, _("The following %u JobId%s will be migrated: %s\n"),
+
+   Jmsg(jcr, M_INFO, 0, _("The following %u JobId%s were chosen to be migrated: %s\n"),
       ids.count, ids.count==0?"":"s", ids.list);
+
    Dmsg2(dbglevel, "Before loop count=%d ids=%s\n", ids.count, ids.list);
    for (int i=1; i < (int)ids.count; i++) {
       JobId = 0;
index e9706c6e0f0408d68affa0c6fe84ecbf28ec2bc9..3a2d160a708a45bc0f6d4b959e2b962b86850ce9 100644 (file)
@@ -123,7 +123,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
       }
       parse_args_only(ua->cmd, &ua->args, &ua->argc, ua->argk, ua->argv, MAX_CMD_ARGS);
       if (ua->argc == 0) {
-         bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n"));
+         bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
          continue;
       }
 
@@ -137,7 +137,7 @@ bool user_select_files_from_tree(TREE_CTX *tree)
             break;
          }
       if (!found) {
-         bsendmsg(tree->ua, _("Illegal command. Enter \"done\" to exit.\n"));
+         bsendmsg(tree->ua, _("Invalid command. Enter \"done\" to exit.\n"));
          continue;
       }
       if (!stat) {
@@ -678,7 +678,7 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree)
 
 
    if (ua->argc != 2) {
-      bsendmsg(ua, _("Too many arguments. Try using double quotes.\n"));
+      bsendmsg(ua, _("Too few or too many arguments. Try using double quotes.\n"));
       return 1;
    }
    node = tree_cwd(ua->argk[1], tree->root, tree->node);
@@ -698,7 +698,11 @@ static int cdcmd(UAContext *ua, TREE_CTX *tree)
       tree->node = node;
    }
    tree_getpath(tree->node, cwd, sizeof(cwd));
-   bsendmsg(ua, _("cwd is: %s\n"), cwd);
+   if (ua->api) {
+      bsendmsg(ua, "%s", cwd);
+   } else {
+      bsendmsg(ua, _("cwd is: %s\n"), cwd);
+   }
    return 1;
 }
 
index 13145ed16433dfcfc7cb13b92affac85a953880d..0a7c416788898dee04db7781e996e48c8bd938f3 100644 (file)
 
 restoreDialog::restoreDialog(Console *console)
 {
+   QStringList titles;
    m_console = console;
   
    m_console->setEnabled(false);
    setupUi(this);
    connect(fileWidget, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), 
            this, SLOT(fileDoubleClicked(QTreeWidgetItem *, int)));
+   connect(upButton, SIGNAL(pressed()), this, SLOT(upButtonPushed()));
+   connect(markButton, SIGNAL(pressed()), this, SLOT(markButtonPushed()));
+   connect(unmarkButton, SIGNAL(pressed()), this, SLOT(unmarkButtonPushed()));
    setFont(m_console->get_font());
    m_console->displayToPrompt();
+
+
+   titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date";
+   fileWidget->setHeaderLabels(titles);
+
+   get_cwd();
    fillDirectory();
    this->show();
 }
@@ -57,23 +67,13 @@ restoreDialog::restoreDialog(Console *console)
  */
 void restoreDialog::fillDirectory()
 {
-   char cd_cmd[MAXSTRING];
    char modes[20], user[20], group[20], size[20], date[30];
    char marked[10];
    int pnl, fnl;
    POOLMEM *file = get_pool_memory(PM_FNAME);
    POOLMEM *path = get_pool_memory(PM_FNAME);
-   QStringList titles;
-
-   titles << "Mark" << "File" << "Mode" << "User" << "Group" << "Size" << "Date";
-   fileWidget->setHeaderLabels(titles);
-
-   char *dir = get_cwd();
-   bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"\n", dir);
-   Dmsg2(100, "dir=%s cmd=%s\n", dir, cd_cmd);
-   m_console->write_dir(cd_cmd);
-   m_console->discardToPrompt();
 
+   fileWidget->clear();
    m_console->write_dir("dir");
    QList<QTreeWidgetItem *> items;
    QStringList item;
@@ -157,8 +157,6 @@ void restoreDialog::reject()
 void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int column)
 {
    char cmd[1000];
-//   printf("cwd=%s Text=%s column=%d\n", m_cwd.toUtf8().data(), 
-//          item->text(1).toUtf8().data(), column);
    if (column == 0) {                 /* mark/unmark */
       if (item->text(0) == "*") {
          bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"\n", item->text(1).toUtf8().data());
@@ -168,12 +166,81 @@ void restoreDialog::fileDoubleClicked(QTreeWidgetItem *item, int column)
          item->setText(0, "*");
       }
       m_console->write(cmd);
-//    printf("cmd=%s", cmd);
       m_console->displayToPrompt();
       return;
+   }    
+   /* 
+    * Double clicking other than column 0 means to decend into
+    *  the directory -- or nothing if it is not a directory.
+    */
+   if (item->text(1).endsWith("/")) {
+      cwd(item->text(1).toUtf8().data());
+      fillDirectory();
+   }
+}
+
+void restoreDialog::upButtonPushed()
+{
+   cwd("..");
+   fillDirectory();
+}
+
+void restoreDialog::markButtonPushed()
+{
+   QList<QTreeWidgetItem *> items = fileWidget->selectedItems();
+   QTreeWidgetItem *item;
+   char cmd[1000];
+   foreach (item, items) {
+      Dmsg1(000, "item=%s\n", item->text(1).toUtf8().data());
+      if (item->text(0) == " ") {
+         bsnprintf(cmd, sizeof(cmd), "mark \"%s\"", item->text(1).toUtf8().data());
+         item->setText(0, "*");
+         m_console->write(cmd);
+         Dmsg1(000, "cmd=%s\n", cmd);
+         m_console->displayToPrompt();
+      }
+   }
+}
+
+void restoreDialog::unmarkButtonPushed()
+{
+   QList<QTreeWidgetItem *> items = fileWidget->selectedItems();
+   QTreeWidgetItem *item;
+   char cmd[1000];
+   foreach (item, items) {
+      if (item->text(0) == "*") {
+         bsnprintf(cmd, sizeof(cmd), "unmark \"%s\"", item->text(1).toUtf8().data());
+         item->setText(0, " ");
+         m_console->write(cmd);
+         Dmsg1(000, "cmd=%s\n", cmd);
+         m_console->displayToPrompt();
+      }
    }
 }
 
+/*
+ * Change current working directory 
+ */
+bool restoreDialog::cwd(const char *dir)
+{
+   int stat;
+   char cd_cmd[MAXSTRING];
+
+   bsnprintf(cd_cmd, sizeof(cd_cmd), "cd \"%s\"\n", dir);
+   Dmsg2(100, "dir=%s cmd=%s\n", dir, cd_cmd);
+   m_console->write_dir(cd_cmd);
+   if ((stat = m_console->read()) > 0) {
+      m_cwd = m_console->msg();
+      Dmsg2(100, "cwd=%s msg=%s\n", m_cwd.toUtf8().data(), m_console->msg());
+   } else {
+      Dmsg1(000, "stat=%d\n", stat);
+   }
+   m_console->discardToPrompt();
+   lineEdit->clear();
+   lineEdit->insert(m_cwd);
+   return true;  /* ***FIXME*** return real status */
+}
+
 /*
  * Return cwd when in tree restore mode 
  */
index 0a15ff9f6c7d6d0b37354d43043c4b71a46ae714..499a316d03bd701b49571c02ec8d1ae6bcc1d0b0 100644 (file)
@@ -75,11 +75,15 @@ public:
    restoreDialog(Console *parent);
    void fillDirectory();
    char *get_cwd();
+   bool cwd(const char *);
 
 private slots:
    void accept();
    void reject();
    void fileDoubleClicked(QTreeWidgetItem *item, int column);
+   void upButtonPushed();
+   void unmarkButtonPushed();
+   void markButtonPushed();
 
 private:
    Console *m_console;
index f2254c45f26a67de9e699313b3b19307e5691487..a746e40c0b75bada388cc92d18a01cbb3a587865 100644 (file)
@@ -5,8 +5,8 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>1196</width>
-    <height>649</height>
+    <width>1285</width>
+    <height>759</height>
    </rect>
   </property>
   <property name="windowTitle" >
    <property name="spacing" >
     <number>6</number>
    </property>
+   <item>
+    <spacer>
+     <property name="orientation" >
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType" >
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" >
+      <size>
+       <width>20</width>
+       <height>16</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
    <item>
     <widget class="QSplitter" name="splitter" >
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <widget class="QWidget" name="" >
+     <widget class="QWidget" name="layoutWidget" >
       <layout class="QVBoxLayout" >
        <property name="margin" >
         <number>0</number>
            <property name="orientation" >
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Preferred</enum>
+           </property>
            <property name="sizeHint" >
             <size>
-             <width>40</width>
-             <height>20</height>
+             <width>50</width>
+             <height>30</height>
             </size>
            </property>
           </spacer>
            <property name="orientation" >
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Preferred</enum>
+           </property>
            <property name="sizeHint" >
             <size>
-             <width>40</width>
-             <height>20</height>
+             <width>50</width>
+             <height>30</height>
             </size>
            </property>
           </spacer>
         <widget class="QTreeWidget" name="treeWidget" >
          <property name="sizePolicy" >
           <sizepolicy>
-           <hsizetype>7</hsizetype>
+           <hsizetype>5</hsizetype>
            <vsizetype>7</vsizetype>
            <horstretch>1</horstretch>
            <verstretch>1</verstretch>
          </property>
          <property name="minimumSize" >
           <size>
-           <width>100</width>
+           <width>60</width>
            <height>0</height>
           </size>
          </property>
          </property>
          <property name="sizeIncrement" >
           <size>
-           <width>0</width>
+           <width>1</width>
+           <height>0</height>
+          </size>
+         </property>
+         <property name="baseSize" >
+          <size>
+           <width>50</width>
            <height>0</height>
           </size>
          </property>
        </item>
       </layout>
      </widget>
-     <widget class="QWidget" name="" >
+     <widget class="QWidget" name="layoutWidget" >
       <layout class="QVBoxLayout" >
        <property name="margin" >
         <number>0</number>
            <property name="orientation" >
             <enum>Qt::Horizontal</enum>
            </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Fixed</enum>
+           </property>
+           <property name="sizeHint" >
+            <size>
+             <width>16</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="upButton" >
+           <property name="sizePolicy" >
+            <sizepolicy>
+             <hsizetype>5</hsizetype>
+             <vsizetype>0</vsizetype>
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text" >
+            <string>Up</string>
+           </property>
+           <property name="icon" >
+            <iconset>../images/up.png</iconset>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer>
+           <property name="orientation" >
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Fixed</enum>
+           </property>
+           <property name="sizeHint" >
+            <size>
+             <width>16</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="markButton" >
+           <property name="sizePolicy" >
+            <sizepolicy>
+             <hsizetype>5</hsizetype>
+             <vsizetype>0</vsizetype>
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text" >
+            <string>Mark</string>
+           </property>
+           <property name="icon" >
+            <iconset>../images/mark.png</iconset>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer>
+           <property name="orientation" >
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Fixed</enum>
+           </property>
+           <property name="sizeHint" >
+            <size>
+             <width>16</width>
+             <height>20</height>
+            </size>
+           </property>
+          </spacer>
+         </item>
+         <item>
+          <widget class="QPushButton" name="unmarkButton" >
+           <property name="sizePolicy" >
+            <sizepolicy>
+             <hsizetype>5</hsizetype>
+             <vsizetype>0</vsizetype>
+             <horstretch>0</horstretch>
+             <verstretch>0</verstretch>
+            </sizepolicy>
+           </property>
+           <property name="text" >
+            <string>Unmark</string>
+           </property>
+           <property name="icon" >
+            <iconset>../images/unmark.png</iconset>
+           </property>
+          </widget>
+         </item>
+         <item>
+          <spacer>
+           <property name="orientation" >
+            <enum>Qt::Horizontal</enum>
+           </property>
+           <property name="sizeType" >
+            <enum>QSizePolicy::Fixed</enum>
+           </property>
            <property name="sizeHint" >
             <size>
              <width>61</width>
            </property>
            <property name="sizeHint" >
             <size>
-             <width>91</width>
-             <height>20</height>
+             <width>261</width>
+             <height>30</height>
             </size>
            </property>
           </spacer>
        <property name="text" >
         <string>Current Dir:</string>
        </property>
+       <property name="buddy" >
+        <cstring>lineEdit</cstring>
+       </property>
       </widget>
      </item>
      <item>
      </property>
      <item>
       <widget class="QLabel" name="label_4" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>0</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
        <property name="text" >
         <string>Status:</string>
        </property>
       </widget>
      </item>
      <item>
-      <widget class="QLineEdit" name="lineEdit_2" />
+      <widget class="QLabel" name="statusLine" >
+       <property name="sizePolicy" >
+        <sizepolicy>
+         <hsizetype>5</hsizetype>
+         <vsizetype>0</vsizetype>
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text" >
+        <string/>
+       </property>
+      </widget>
      </item>
     </layout>
    </item>
   </layout>
+  <action name="actionUp" >
+   <property name="icon" >
+    <iconset>../images/up.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Up</string>
+   </property>
+  </action>
+  <action name="actionMark" >
+   <property name="icon" >
+    <iconset>../images/mark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Mark</string>
+   </property>
+  </action>
+  <action name="actionUnmark" >
+   <property name="icon" >
+    <iconset>../images/unmark.png</iconset>
+   </property>
+   <property name="text" >
+    <string>Unmark</string>
+   </property>
+  </action>
  </widget>
  <resources/>
  <connections>
    <slot>accept()</slot>
    <hints>
     <hint type="sourcelabel" >
-     <x>248</x>
-     <y>254</y>
+     <x>955</x>
+     <y>719</y>
     </hint>
     <hint type="destinationlabel" >
      <x>157</x>
    <slot>reject()</slot>
    <hints>
     <hint type="sourcelabel" >
-     <x>316</x>
-     <y>260</y>
+     <x>1023</x>
+     <y>719</y>
     </hint>
     <hint type="destinationlabel" >
      <x>286</x>