~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/clients/qmon/qmon_message.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 * 
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
#include <stdio.h>
 
33
#include <stdlib.h>
 
34
 
 
35
#include <Xm/Xm.h>
 
36
#include <Xm/Text.h>
 
37
 
 
38
#include <Xmt/Xmt.h>
 
39
#include <Xmt/MsgLine.h>
 
40
#include <Xmt/Dialogs.h>
 
41
#include <Xmt/Create.h>
 
42
 
 
43
#include "qmon_rmon.h"
 
44
#include "qmon_cull.h"
 
45
#include "qmon_message.h"
 
46
#include "qmon_browser.h"
 
47
#include "qmon_appres.h"
 
48
#include "sge_answer.h"
 
49
 
 
50
static Widget qmon_msg_box = 0;
 
51
static Widget msg_text_w = 0;
 
52
 
 
53
static Boolean message_blocked = False;
 
54
 
 
55
 
 
56
static Widget qmonMessageCreateMsgBox(Widget parent);
 
57
static void qmonMessageOk(Widget w, XtPointer cld, XtPointer cad);
 
58
 
 
59
/*-------------------------------------------------------------------------*/
 
60
void qmonMessageShow(Widget w, Boolean msg_box, StringConst fmt, ...)
 
61
{
 
62
   va_list arg_list;
 
63
   char buf[BUFSIZ];
 
64
   char *l10nfmt;
 
65
   
 
66
   DENTER(GUI_LAYER, "qmonMessageShow");
 
67
 
 
68
   Va_start(arg_list, fmt);
 
69
 
 
70
#if 0
 
71
   switch (MSG_HOW) {
 
72
      case MSG_MSGLINE:
 
73
      
 
74
         (void) vsprintf(buf, fmt, arg_list);
 
75
         XmtMsgLineSet(w, buf);
 
76
         XmtMsgLineClear(w, DISPLAY_MESSAGE_DURATION);
 
77
         break;
 
78
      
 
79
      case MSG_BROWSER:
 
80
#endif
 
81
         l10nfmt = XmtLocalize(w, fmt, fmt);
 
82
         (void)vsprintf(buf, l10nfmt, arg_list);
 
83
         if (qmonBrowserObjectEnabled(BROWSE_MSG)) {
 
84
            qmonBrowserShow(buf);
 
85
            qmonBrowserShow("\n");
 
86
         }
 
87
 
 
88
         if (msg_box) {
 
89
            XmtDisplayWarningMsg(w, "XmtMessageBox", buf, "Warning", NULL);
 
90
            XSync(XtDisplay(w), 0);
 
91
            XmUpdateDisplay(w);
 
92
         }
 
93
#if 0         
 
94
         break;
 
95
         
 
96
      default:
 
97
         DPRINTF(("No valid Message Type\n"));
 
98
   }
 
99
         
 
100
#endif
 
101
   
 
102
   DEXIT;
 
103
}
 
104
 
 
105
 
 
106
/*-------------------------------------------------------------------------*/
 
107
int qmonMessageBox(
 
108
Widget parent,
 
109
lList *alp,
 
110
int show_always 
 
111
) {
 
112
   lListElem *aep = NULL;
 
113
   XmTextPosition pos;
 
114
   Boolean error = False;
 
115
   StringConst msg;
 
116
   u_long32 as = 0;
 
117
   u_long32 aq = 0;
 
118
   Boolean show = False;
 
119
 
 
120
   DENTER(GUI_LAYER, "qmonMessageBox");
 
121
 
 
122
   DPRINTF(("show_always = %d\n", show_always));
 
123
 
 
124
   if (!alp || !parent) {
 
125
      DEXIT;
 
126
      return -1;
 
127
   }
 
128
 
 
129
   /*
 
130
   ** create the Message Box if necessary
 
131
   */
 
132
   if (!qmon_msg_box) {
 
133
      qmon_msg_box = qmonMessageCreateMsgBox(parent);
 
134
   }
 
135
 
 
136
   /*
 
137
   ** fill the message texts into the text field
 
138
   */
 
139
   XmTextDisableRedisplay(msg_text_w);
 
140
   pos = 0;
 
141
   XmTextSetString(msg_text_w, "");
 
142
   /*
 
143
   ** extract messages
 
144
   */
 
145
   for_each(aep, alp) {
 
146
      as = lGetUlong(aep, AN_status);
 
147
      aq = lGetUlong(aep, AN_quality);
 
148
      msg = lGetString(aep, AN_text);
 
149
 
 
150
      if (qmonBrowserObjectEnabled(BROWSE_MSG)) {
 
151
         qmonBrowserShow(msg);
 
152
         qmonBrowserShow("\n");
 
153
      }
 
154
 
 
155
      if (!msg)
 
156
         continue;
 
157
      if (aq == ANSWER_QUALITY_ERROR)
 
158
         error = True;
 
159
      if ((as != STATUS_OK) || show_always) { 
 
160
         show = True;
 
161
         /* FIX_CONST_GUI */
 
162
         XmTextInsert(msg_text_w, pos, (String)msg);
 
163
         pos += strlen(msg);
 
164
         XmTextInsert(msg_text_w, pos, "\n");
 
165
         pos += strlen("\n");
 
166
      }
 
167
   }
 
168
   XmTextShowPosition(msg_text_w, 0);
 
169
   XmTextEnableRedisplay(msg_text_w);
 
170
   
 
171
   /*
 
172
   ** manage the msg_box
 
173
   */
 
174
   if (show) {
 
175
      XtManageChild(qmon_msg_box);
 
176
      XSync(XtDisplay(parent), 0);
 
177
      XmUpdateDisplay(parent);
 
178
      message_blocked = True;
 
179
      XmtBlock(qmon_msg_box, &message_blocked);
 
180
   }
 
181
 
 
182
   
 
183
   if (error) {
 
184
      DEXIT;
 
185
      return -1;
 
186
   }
 
187
 
 
188
   DEXIT;
 
189
   return 0;
 
190
}
 
191
 
 
192
/*-------------------------------------------------------------------------*/
 
193
static Widget qmonMessageCreateMsgBox(
 
194
Widget parent 
 
195
) {
 
196
   Widget msg_layout, msg_ok;
 
197
 
 
198
   DENTER(GUI_LAYER, "qmonMessageCreateMsgBox");
 
199
   
 
200
   msg_layout = XmtBuildQueryDialog( parent, "qmon_msg_box",
 
201
                           NULL, 0,
 
202
                           "msg_text", &msg_text_w,
 
203
                           "msg_ok", &msg_ok,
 
204
                           NULL);
 
205
   XtAddCallback(msg_ok, XmNactivateCallback,
 
206
                  qmonMessageOk, NULL);
 
207
 
 
208
   DEXIT;
 
209
   return msg_layout;
 
210
}
 
211
 
 
212
 
 
213
/*-------------------------------------------------------------------------*/
 
214
static void qmonMessageOk(Widget w, XtPointer cld, XtPointer cad)
 
215
{
 
216
   DENTER(GUI_LAYER, "qmonMessageOk");
 
217
 
 
218
   message_blocked = False;
 
219
 
 
220
   DEXIT;
 
221
}
 
222
 
 
223
 
 
224
 
 
225
 
 
226
 
 
227
#if 0
 
228
         for_each(aep, alp) {
 
229
            u_long32 quality;
 
230
 
 
231
            answer_status = lGetUlong(aep, AN_status);
 
232
            quality = lGetUlong(aep, AN_quality);
 
233
            if (quality == ANSWER_QUALITY_ERROR) {
 
234
               sprintf(msg, "%s\nPlease correct above errors first !\n", 
 
235
                        lGetString(aep, AN_text));
 
236
               qmonMessageShow(w, True, msg);
 
237
               DEXIT;
 
238
               return;
 
239
            }
 
240
            else if (quality == ANSWER_QUALITY_WARNING) {
 
241
               sprintf(msg, "WARNING!\n%s\n", 
 
242
                        lGetString(aep, AN_text));
 
243
               qmonMessageShow(w, True, msg);
 
244
            }
 
245
            else if (quality == ANSWER_QUALITY_INFO) {
 
246
               qmonMessageShow(w, True, lGetString(aep, AN_text));
 
247
            }
 
248
         }
 
249
#endif