Changeset 128 in MondoRescue for branches/2.05/mondo/mondo/common/X-specific.h


Ignore:
Timestamp:
Nov 19, 2005, 2:27:41 AM (18 years ago)
Author:
bcornec
Message:

indent on all the C code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.05/mondo/mondo/common/X-specific.h

    r30 r128  
    77#endif
    88
    9 int  ask_me_yes_or_no (char *prompt);
    10 int  ask_me_OK_or_cancel (char *prompt);
    11 void close_evalcall_form (void);
    12 void close_progress_form ();
    13 void fatal_error (char *error_string);
    14 void fatal_error_sub (char *error_string);
    15 void finish (int signal);
    16 void mvaddstr_and_log_it (int y, int x, char *output);
    17 void log_file_end_to_screen (char *filename, char *grep_for_me);
    18 void log_to_screen (const char *op, ...);
    19 void open_evalcall_form (char *title);
    20 void open_progress_form (char *title, char *b1, char *b2, char *b3, long max_val);
    21 void popup_and_OK (char *prompt);
    22 void popup_and_OK_sub (char *prompt);
    23 int  popup_and_get_string (char *title, char *b, char *output, int maxsize);
    24 int  popup_and_get_string_sub (char *title, char *b, char *output, int maxsize);
    25 int  popup_with_buttons (char *p, char *button1, char *button2);
    26 int  popup_with_buttons_sub (char *p, char *button1, char *button2);
    27 void refresh_log_screen ();
    28 void setup_newt_stuff ();
    29 void update_evalcall_form_ratio (int num, int denom);
    30 void update_evalcall_form (int curr);
    31 void update_progress_form (char *blurb3);
    32 void update_progress_form_full (char *blurb1, char *blurb2, char *blurb3);
    33 
    34 
    35 
    36 
    37 
    38 
    39 t_bkptype which_backup_media_type (bool);
    40 int which_compression_level ();
    41 
    42 void popup_chaneglist_from_file(char*source_file);
     9    int ask_me_yes_or_no(char *prompt);
     10    int ask_me_OK_or_cancel(char *prompt);
     11    void close_evalcall_form(void);
     12    void close_progress_form();
     13    void fatal_error(char *error_string);
     14    void fatal_error_sub(char *error_string);
     15    void finish(int signal);
     16    void mvaddstr_and_log_it(int y, int x, char *output);
     17    void log_file_end_to_screen(char *filename, char *grep_for_me);
     18    void log_to_screen(const char *op, ...);
     19    void open_evalcall_form(char *title);
     20    void open_progress_form(char *title, char *b1, char *b2, char *b3,
     21                            long max_val);
     22    void popup_and_OK(char *prompt);
     23    void popup_and_OK_sub(char *prompt);
     24    int popup_and_get_string(char *title, char *b, char *output,
     25                             int maxsize);
     26    int popup_and_get_string_sub(char *title, char *b, char *output,
     27                                 int maxsize);
     28    int popup_with_buttons(char *p, char *button1, char *button2);
     29    int popup_with_buttons_sub(char *p, char *button1, char *button2);
     30    void refresh_log_screen();
     31    void setup_newt_stuff();
     32    void update_evalcall_form_ratio(int num, int denom);
     33    void update_evalcall_form(int curr);
     34    void update_progress_form(char *blurb3);
     35    void update_progress_form_full(char *blurb1, char *blurb2,
     36                                   char *blurb3);
     37
     38
     39
     40
     41
     42
     43    t_bkptype which_backup_media_type(bool);
     44    int which_compression_level();
     45
     46    void popup_chaneglist_from_file(char *source_file);
    4347
    4448#if __cplusplus && WITH_X
    4549
    46 extern int g_result_of_last_event;
    47    
    48 } /* extern "C" */
    49 
     50    extern int g_result_of_last_event;
     51
     52}                               /* extern "C" */
    5053#include <qvaluelist.h>
    5154#include <qwidget.h>
     
    5457#include <qstring.h>
    5558#include <qmultilineedit.h>
    56 
    5759/**
    5860 * A class for XMondo to hold events queued by the backup thread until the event thread is able to handle them.
    59  */
    60 class XMEventHolder
     61 */ class XMEventHolder
    6162{
    62 public:
    63     struct Event
    64     {
    65     enum EventType { None, Show, Hide, New, SetProgress, SetTotal, SetText, InsLine, PopupWithButtons, InfoMsg, ErrorMsg, GetInfo } type;
    66     QWidget *data;
     63  public:
     64    struct Event {
     65        enum EventType { None, Show, Hide, New, SetProgress, SetTotal,
     66                SetText, InsLine, PopupWithButtons, InfoMsg, ErrorMsg,
     67                GetInfo } type;
     68        QWidget *data;
    6769// union {
    68         int iParam;
    69         QString qsParam, title, text, b1, b2;
    70         char *csParam;
    71     int len;
     70        int iParam;
     71        QString qsParam, title, text, b1, b2;
     72        char *csParam;
     73        int len;
    7274// };
    73        
    74     Event() : type (None), data (0) {}
    75     Event (EventType thetype, QWidget *thedata) {
    76         this->type = thetype;
    77         this->data = thedata;
    78     }
    79     Event (EventType thetype, QWidget *thedata, int ip) {
    80         this->type = thetype;
    81         this->data = thedata;
    82         this->iParam = ip;
    83     }
    84     Event (EventType thetype, QWidget *thedata, QString qsp) {
    85         this->type = thetype;
    86         this->data = thedata;
    87         this->qsParam = qsp;
    88     }
    89     Event (EventType thetype, QWidget *thedata, char *csp) {
    90         this->type = thetype;
    91         this->data = thedata;
    92         this->csParam = csp;
    93     }
    94     Event (EventType thetype, QWidget *thedata, char *csp, int len) {
    95         this->type = thetype;
    96         this->data = thedata;
    97         this->csParam = csp;
    98         this->len = len;
    99     }
    100     };
    101    
    102     XMEventHolder() {}
    103 
    104     /* Backup thread functions */
    105 
    106     void event (Event::EventType type, QWidget *data) {
    107     _events.push_back (Event (type, data));
    108     }
    109 
    110     /**
     75
     76         Event():type(None), data(0) {
     77        } Event(EventType thetype, QWidget * thedata) {
     78            this->type = thetype;
     79            this->data = thedata;
     80        } Event(EventType thetype, QWidget * thedata, int ip) {
     81            this->type = thetype;
     82            this->data = thedata;
     83            this->iParam = ip;
     84        }
     85        Event(EventType thetype, QWidget * thedata, QString qsp) {
     86            this->type = thetype;
     87            this->data = thedata;
     88            this->qsParam = qsp;
     89        }
     90        Event(EventType thetype, QWidget * thedata, char *csp) {
     91            this->type = thetype;
     92            this->data = thedata;
     93            this->csParam = csp;
     94        }
     95        Event(EventType thetype, QWidget * thedata, char *csp, int len) {
     96            this->type = thetype;
     97            this->data = thedata;
     98            this->csParam = csp;
     99            this->len = len;
     100        }
     101    };
     102
     103    XMEventHolder() {
     104    }
     105
     106    /* Backup thread functions */
     107
     108    void event(Event::EventType type, QWidget * data) {
     109        _events.push_back(Event(type, data));
     110    }
     111
     112    /**
    111113     * Queue a "show" event for @p data.
    112114     * This is equivalent to a delayed call of @p data->show().
    113115     * @param data The widget to show when the event is processed.
    114116     */
    115     void show (QWidget *data) {
    116     _events.push_back (Event (Event::Show, data));
    117     }
    118 
    119     /**
     117    void show(QWidget * data) {
     118        _events.push_back(Event(Event::Show, data));
     119    }
     120
     121    /**
    120122     * Queue a "hide" event for @p data.
    121123     * This is equivalent to a delayed call of @p data->hide().
    122124     * @param data The widget to hide when the event is processed.
    123125     */
    124     void hide (QWidget *data) {
    125     _events.push_back (Event (Event::Hide, data));
    126     }
    127 
    128     /**
     126    void hide(QWidget * data) {
     127        _events.push_back(Event(Event::Hide, data));
     128    }
     129
     130    /**
    129131     * Queue a "setProgress" event for @p data.
    130132     * This is equivalent to a delayed call of <tt>data-\>setProgress(progress)</tt>.
     
    132134     * @param progress The progress amount to set it to.
    133135     */
    134     void setProgress (QProgressBar *data, int progress) {
    135     _events.push_back (Event (Event::SetProgress, data, progress));
    136     }
    137 
    138     /**
     136    void setProgress(QProgressBar * data, int progress) {
     137        _events.push_back(Event(Event::SetProgress, data, progress));
     138    }
     139
     140    /**
    139141     * Queue a "setTotalSteps" event for @p data.
    140142     * This is equivalent to a delayed call of <tt>data-\>setTotalSteps(totals)</tt>.
     
    142144     * @param totals The total number of steps to set.
    143145     */
    144     void setTotalSteps (QProgressBar *data, int totals) {
    145     _events.push_back (Event (Event::SetTotal, data, totals));
    146     }
    147 
    148     /**
     146    void setTotalSteps(QProgressBar * data, int totals) {
     147        _events.push_back(Event(Event::SetTotal, data, totals));
     148    }
     149
     150    /**
    149151     * Queue a "setText" event for @p data.
    150152     * This is equivalent to a delayed call of <tt>data-\>setText(text)</tt>.
     
    152154     * @param text The text to set it to.
    153155     */
    154     void setText (QLabel *data, QString text) {
    155     _events.push_back (Event (Event::SetText, data, text));
    156     }
    157 
    158     /**
     156    void setText(QLabel * data, QString text) {
     157        _events.push_back(Event(Event::SetText, data, text));
     158    }
     159
     160    /**
    159161     * Queue an "insertLine" event for @p data.
    160162     * This is equivalent to a delayed call of <tt>data->insertLine(line)</tt>.
     
    162164     * @param line The line to add.
    163165     */
    164     void insertLine (QMultiLineEdit *data, QString line) {
    165     _events.push_back (Event (Event::InsLine, data, line));
    166     }
    167 
    168     /**
     166    void insertLine(QMultiLineEdit * data, QString line) {
     167        _events.push_back(Event(Event::InsLine, data, line));
     168    }
     169
     170    /**
    169171     * Queue an alert box with two buttons to be displayed.
    170172     * The button pushed (the return value of popup_with_buttons()) will be stored
     
    174176     * @param b2 The second button's text.
    175177     */
    176     void popupWithButtons (QString text, QString b1, QString b2) {
    177     Event e;
    178     e.type = Event::PopupWithButtons;
    179     e.text = text;
    180     e.b1    = b1;
    181     e.b2    = b2;
    182     _events.push_back (e);
    183     }
    184 
    185     /**
     178    void popupWithButtons(QString text, QString b1, QString b2) {
     179        Event e;
     180        e.type = Event::PopupWithButtons;
     181        e.text = text;
     182        e.b1 = b1;
     183        e.b2 = b2;
     184        _events.push_back(e);
     185    }
     186
     187    /**
    186188     * Queue an info box with one OK button to be displayed.
    187189     * @param text The text of the dialog box.
    188190     */
    189     void infoMsg (QString text) {
    190     Event e;
    191     e.type = Event::InfoMsg;
    192     e.text = text;
    193     _events.push_back (e);
    194     }
    195 
    196     /**
     191    void infoMsg(QString text) {
     192        Event e;
     193        e.type = Event::InfoMsg;
     194        e.text = text;
     195        _events.push_back(e);
     196    }
     197
     198    /**
    197199     * Queue a "fatal error" message.
    198200     * @param text The fatal error.
    199201     */
    200     void errorMsg (QString text) {
    201     Event e;
    202     e.type = Event::ErrorMsg;
    203     e.text = text;
    204     _events.push_back (e);
    205     }
    206 
    207     /**
     202    void errorMsg(QString text) {
     203        Event e;
     204        e.type = Event::ErrorMsg;
     205        e.text = text;
     206        _events.push_back(e);
     207    }
     208
     209    /**
    208210     * Queue a request for some information from the user.
    209211     * If you want to wait until the text is stored, you can set @p g_result_of_last_event
     
    215217     * @param len The size of the buffer allocated for @p out.
    216218     */
    217     void getInfo (QString title, QString text, char *out, int len) {
    218     Event e;
    219     e.type    = Event::GetInfo;
    220     e.title  = title;
    221     e.text    = text;
    222     e.csParam = out;
    223     e.len    = len;
    224     _events.push_back (e);
    225     }
    226    
    227     /* These are called in the GUI thread */
    228 
    229     /**
     219    void getInfo(QString title, QString text, char *out, int len) {
     220        Event e;
     221        e.type = Event::GetInfo;
     222        e.title = title;
     223        e.text = text;
     224        e.csParam = out;
     225        e.len = len;
     226        _events.push_back(e);
     227    }
     228
     229    /* These are called in the GUI thread */
     230
     231    /**
    230232     * Clear all events stored in the queue without executing them.
    231233     */
    232     void clear() {
    233     _events.erase (_events.begin(), _events.end());
    234     }
    235 
    236     /**
     234    void clear() {
     235        _events.erase(_events.begin(), _events.end());
     236    }
     237
     238    /**
    237239     * Process all events stored in the queue and then clear them.
    238240     */
    239     void send() {
    240         QProgressBar *pb;
    241         QLabel *l;
    242     QMultiLineEdit *mle;
    243     for (QValueList <Event>::iterator it = _events.begin(); it != _events.end(); ++it) {
    244         switch ((*it).type) {
    245         case Event::Show:
    246         ((*it).data)->show();
    247         break;
    248         case Event::Hide:
    249         ((*it).data)->hide();
    250         break;
    251         case Event::SetProgress:
    252         if ((pb = dynamic_cast <QProgressBar*> ((*it).data))) {
    253             pb->setProgress ((*it).iParam);
    254         }
    255         break;
    256         case Event::SetTotal:
    257         if ((pb = dynamic_cast <QProgressBar*> ((*it).data))) {
    258             pb->setTotalSteps ((*it).iParam);
    259         }
    260         break;
    261         case Event::SetText:
    262         if ((l = dynamic_cast <QLabel*> ((*it).data))) {
    263             l->setText ((*it).qsParam);
    264         }
    265         break;
    266         case Event::InsLine:
    267         if ((mle = dynamic_cast <QMultiLineEdit *> ((*it).data))) {
    268             mle->insertLine ((*it).qsParam);
    269         }
    270         break;
    271         case Event::PopupWithButtons:
    272         g_result_of_last_event = popup_with_buttons_sub (const_cast <char*> ((*it).text.ascii()), const_cast <char*> ((*it).b1.ascii()), const_cast <char*> ((*it).b2.ascii()));
    273         break;
    274         case Event::InfoMsg:
    275         popup_and_OK_sub (const_cast <char*> ((*it).text.ascii()));
    276         g_result_of_last_event = 0;
    277         break;
    278         case Event::ErrorMsg:
    279         fatal_error_sub (const_cast <char*> ((*it).text.ascii()));
    280         break;
    281         case Event::GetInfo:
    282         g_result_of_last_event = popup_and_get_string_sub (const_cast <char*> ((*it).title.ascii()), const_cast <char*> ((*it).text.ascii()), (*it).csParam, (*it).len);
    283         break;
    284         default:
    285         qDebug ("unknown event\n");
    286         }
    287     }
    288     this->clear();
    289     }
    290    
    291     /* Undocumented */
    292     QValueList <Event> events() {
    293     return _events;
    294     }
    295    
    296 protected:
    297    
    298 
    299     QValueList <Event> _events;
     241    void send() {
     242        QProgressBar *pb;
     243        QLabel *l;
     244        QMultiLineEdit *mle;
     245        for (QValueList < Event >::iterator it = _events.begin();
     246             it != _events.end(); ++it) {
     247            switch ((*it).type) {
     248            case Event::Show:
     249                ((*it).data)->show();
     250                break;
     251            case Event::Hide:
     252                ((*it).data)->hide();
     253                break;
     254            case Event::SetProgress:
     255                if ((pb = dynamic_cast < QProgressBar * >((*it).data))) {
     256                    pb->setProgress((*it).iParam);
     257                }
     258                break;
     259            case Event::SetTotal:
     260                if ((pb = dynamic_cast < QProgressBar * >((*it).data))) {
     261                    pb->setTotalSteps((*it).iParam);
     262                }
     263                break;
     264            case Event::SetText:
     265                if ((l = dynamic_cast < QLabel * >((*it).data))) {
     266                    l->setText((*it).qsParam);
     267                }
     268                break;
     269            case Event::InsLine:
     270                if ((mle = dynamic_cast < QMultiLineEdit * >((*it).data))) {
     271                    mle->insertLine((*it).qsParam);
     272                }
     273                break;
     274            case Event::PopupWithButtons:
     275                g_result_of_last_event =
     276                    popup_with_buttons_sub(const_cast <
     277                                           char *>((*it).text.ascii()),
     278                                           const_cast <
     279                                           char *>((*it).b1.ascii()),
     280                                           const_cast <
     281                                           char *>((*it).b2.ascii()));
     282                break;
     283            case Event::InfoMsg:
     284                popup_and_OK_sub(const_cast < char *>((*it).text.ascii()));
     285                g_result_of_last_event = 0;
     286                break;
     287            case Event::ErrorMsg:
     288                fatal_error_sub(const_cast < char *>((*it).text.ascii()));
     289                break;
     290            case Event::GetInfo:
     291                g_result_of_last_event =
     292                    popup_and_get_string_sub(const_cast <
     293                                             char *>((*it).title.ascii()),
     294                                             const_cast <
     295                                             char *>((*it).text.ascii()),
     296                                             (*it).csParam, (*it).len);
     297                break;
     298            default:
     299                qDebug("unknown event\n");
     300            }
     301        }
     302        this->clear();
     303    }
     304
     305    /* Undocumented */
     306    QValueList < Event > events() {
     307        return _events;
     308    }
     309
     310  protected:
     311
     312
     313    QValueList < Event > _events;
    300314};
    301  
    302 #endif /* __cplusplus */
     315
     316#endif                          /* __cplusplus */
Note: See TracChangeset for help on using the changeset viewer.