~openerp-commiter/openobject-addons/extra-6.0

« back to all changes in this revision

Viewing changes to openerp-outlook-plugin/dialogs/dialog_map.py

  • Committer: pap(openerp)
  • Date: 2010-01-11 13:58:16 UTC
  • Revision ID: pap@tinyerp.co.in-20100111135816-oxe0n3xsst2me3vu
[ADD]:added new module openerp-outlook-plugin

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from processors import *
 
2
from opt_processors import *
 
3
import sys
 
4
import os
 
5
import addin
 
6
from dialogs import ShowDialog, MakePropertyPage#, ShowWizard
 
7
 
 
8
import win32ui
 
9
import win32api
 
10
import commctrl
 
11
import win32con
 
12
import win32gui
 
13
import win32com
 
14
import win32gui_struct
 
15
import pywintypes
 
16
import xmlrpclib
 
17
 
 
18
try:
 
19
    enumerate
 
20
except NameError:   # enumerate new in 2.3
 
21
    def enumerate(seq):
 
22
        return [(i, seq[i]) for i in xrange(len(seq))]
 
23
 
 
24
BIF_NEWDIALOGSTYLE = 0x00000040
 
25
BIF_NONEWFOLDERBUTTON = 0x0000200
 
26
CSIDL_COMMONMYPICTURES = 0x00000036
 
27
 
 
28
class _WIN32MASKEDSTRUCT:
 
29
    def __init__(self, **kw):
 
30
        full_fmt = ""
 
31
        for name, fmt, default, mask in self._struct_items_:
 
32
            self.__dict__[name] = None
 
33
            if fmt == "z":
 
34
                full_fmt += "pi"
 
35
            else:
 
36
                full_fmt += fmt
 
37
        for name, val in kw.iteritems():
 
38
            if name not in self.__dict__:
 
39
                raise ValueError("LVITEM structures do not have an item '%s'" % (name,))
 
40
            self.__dict__[name] = val
 
41
 
 
42
    def __setattr__(self, attr, val):
 
43
        if not attr.startswith("_") and attr not in self.__dict__:
 
44
            raise AttributeError(attr)
 
45
        self.__dict__[attr] = val
 
46
 
 
47
    def toparam(self):
 
48
        self._buffs = []
 
49
        full_fmt = ""
 
50
        vals = []
 
51
        mask = 0
 
52
        # calc the mask
 
53
        for name, fmt, default, this_mask in self._struct_items_:
 
54
            if this_mask is not None and self.__dict__.get(name) is not None:
 
55
                mask |= this_mask
 
56
        self.mask = mask
 
57
        for name, fmt, default, this_mask in self._struct_items_:
 
58
            val = self.__dict__[name]
 
59
            if fmt == "z":
 
60
                fmt = "Pi"
 
61
                if val is None:
 
62
                    vals.append(0)
 
63
                    vals.append(0)
 
64
                else:
 
65
                    # Note this demo still works with byte strings.  An
 
66
                    # alternate strategy would be to use unicode natively
 
67
                    # and use the 'W' version of the messages - eg,
 
68
                    # LVM_SETITEMW etc.
 
69
                    val = val + "\0"
 
70
                    if isinstance(val, unicode):
 
71
                        val = val.encode("mbcs")
 
72
                    str_buf = array.array("b", val)
 
73
                    vals.append(str_buf.buffer_info()[0])
 
74
                    vals.append(len(val))
 
75
                    self._buffs.append(str_buf) # keep alive during the call.
 
76
            else:
 
77
                if val is None:
 
78
                    val = default
 
79
                vals.append(val)
 
80
            full_fmt += fmt
 
81
        return struct.pack(*(full_fmt,) + tuple(vals))
 
82
 
 
83
 
 
84
# NOTE: See the win32gui_struct module for an alternative way of dealing
 
85
# with these structures
 
86
class LVITEM(_WIN32MASKEDSTRUCT):
 
87
    _struct_items_ = [
 
88
        ("mask", "I", 0, None),
 
89
        ("iItem", "i", 0, None),
 
90
        ("iSubItem", "i", 0, None),
 
91
        ("state", "I", 0, commctrl.LVIF_STATE),
 
92
        ("stateMask", "I", 0, None),
 
93
        ("text", "z", None, commctrl.LVIF_TEXT),
 
94
        ("iImage", "i", 0, commctrl.LVIF_IMAGE),
 
95
        ("lParam", "i", 0, commctrl.LVIF_PARAM),
 
96
        ("iIdent", "i", 0, None),
 
97
        ("cchTextMax", "i", 0, 255),
 
98
        ("pszText", "i", 0, None),
 
99
        ("flags", "i", 0, None),
 
100
    ]
 
101
 
 
102
class LVCOLUMN(_WIN32MASKEDSTRUCT):
 
103
    _struct_items_ = [
 
104
        ("mask", "I", 0, None),
 
105
        ("fmt", "i", 0, commctrl.LVCF_FMT),
 
106
        ("cx", "i", 0, commctrl.LVCF_WIDTH),
 
107
        ("text", "z", None, commctrl.LVCF_TEXT),
 
108
        ("iSubItem", "i", 0, commctrl.LVCF_SUBITEM),
 
109
        ("iImage", "i", 0, commctrl.LVCF_IMAGE),
 
110
        ("iOrder", "i", 0, commctrl.LVCF_ORDER),
 
111
    ]
 
112
 
 
113
global flag_stop
 
114
flag_stop=win32con.MB_ICONSTOP
 
115
 
 
116
global flag_error
 
117
flag_error=win32con.MB_ICONERROR
 
118
 
 
119
global flag_info
 
120
flag_info=win32con.MB_ICONINFORMATION
 
121
 
 
122
global flag_excl
 
123
flag_excl=win32con.MB_ICONEXCLAMATION
 
124
 
 
125
global NewConn
 
126
NewConn=addin.GetConn()
 
127
 
 
128
## Retrieves current XMLRPC connection
 
129
def GetConn():
 
130
    return NewConn
 
131
 
 
132
global objects_with_match
 
133
objects_with_match=[]
 
134
 
 
135
global hwndChk_list
 
136
hwndChk_list=[]
 
137
 
 
138
global search_text
 
139
search_text='search_text'
 
140
 
 
141
global name
 
142
name=''
 
143
global email
 
144
email=''
 
145
 
 
146
def check():
 
147
    server = NewConn._server
 
148
    port = NewConn._port
 
149
    NewConn.GetDBList()
 
150
    if not NewConn._running:
 
151
        win32ui.MessageBox("No server running on host "+ server+" at port "+str(port), "Server Connection", flag_excl)
 
152
        return False
 
153
    if not NewConn._login:
 
154
        win32ui.MessageBox("Please login to the database first", "Database Connection", flag_excl)
 
155
        return False
 
156
    return True
 
157
 
 
158
 
 
159
def resetConnAttribs(window):
 
160
    config = window.manager.LoadConfig()
 
161
    NewConn._server = config['server']
 
162
    NewConn._port = config['port']
 
163
    NewConn._uri = "http://" + config['server'] + ":" + str(config['port'])
 
164
    NewConn._obj_list = config['objects']
 
165
    NewConn._dbname = config['database']
 
166
    NewConn._uname = config['uname']
 
167
    NewConn._pwd = config['pwd']
 
168
    NewConn._login = config['login']
 
169
    return
 
170
 
 
171
def setConnAttribs(server, port, manager):
 
172
    uri = 'http://' + server + ":" + str(port)
 
173
    NewConn.__init__(server,port,uri)
 
174
    NewConn.GetDBList()
 
175
    manager.config = manager.LoadConfig()
 
176
    NewConn._obj_list = manager.config['objects']
 
177
    NewConn._dbname = manager.config['database']
 
178
    NewConn._uname = manager.config['uname']
 
179
    NewConn._pwd = manager.config['pwd']
 
180
    NewConn._login = manager.config['login']
 
181
    return
 
182
 
 
183
def getConnAttributes(manager):
 
184
    manager.config['server'] = NewConn._server
 
185
    manager.config['port'] = NewConn._port
 
186
    manager.config['objects'] = NewConn._obj_list
 
187
    manager.config['database'] = NewConn._dbname
 
188
    manager.config['uname'] = NewConn._uname
 
189
    manager.config['pwd'] = NewConn._pwd
 
190
    manager.config['login'] = NewConn._login
 
191
    return
 
192
 
 
193
def getMessage(e):
 
194
    print "Exception %s: %s"%(type(e),str(e))
 
195
    msg = str(e)
 
196
    if type(e) == pywintypes.com_error:
 
197
        msg="Access to the mail Denied"
 
198
    elif type(e) == xmlrpclib.Fault:
 
199
        msg = str(e.faultCode) or e.faultString or e.message or str(e)
 
200
    else:
 
201
        if hasattr(e, 'faultCode') and e.faultCode:
 
202
            msg = str(e.faultCode)
 
203
        elif hasattr(e, 'faultString') and e.faultString:
 
204
            msg = e.faultString
 
205
        elif hasattr(e, 'message') and e.message:
 
206
            msg = e.message
 
207
    return msg
 
208
    
 
209
class OKButtonProcessor(ButtonProcessor):
 
210
    def __init__(self, window, control_ids):
 
211
        self.mngr = window.manager
 
212
        ControlProcessor.__init__(self, window, control_ids)
 
213
 
 
214
    def OnClicked(self, id):
 
215
        server = win32gui.GetDlgItemText(self.window.hwnd, self.other_ids[0])
 
216
        try:
 
217
            port = int(win32gui.GetDlgItemText(self.window.hwnd, self.other_ids[1]))
 
218
        except ValueError, e:
 
219
            print "Exception %s: %s"%str(e)
 
220
            win32ui.MessageBox("Port should be an integer", "Error", flag_excl)
 
221
            return
 
222
        except Exception,e:
 
223
            msg = getMessage(e)
 
224
            win32ui.MessageBox(msg, "Error", flag_excl)
 
225
            return
 
226
        setConnAttribs(server, port, self.mngr)
 
227
        if NewConn._running == False:
 
228
                msg = "No server running on host '%s' at port '%d'. Press ignore to still continue with this configuration?"%(server,port)
 
229
                r=win32ui.MessageBox(msg, "Server Connection", win32con.MB_ABORTRETRYIGNORE | win32con.MB_ICONQUESTION)
 
230
                if r==3:
 
231
                                resetConnAttribs(self.window)
 
232
                                return
 
233
                elif r==4:
 
234
                        self.OnClicked(id)
 
235
                elif r==5:
 
236
                        setConnAttribs(server, port, self.mngr)
 
237
        win32gui.EndDialog(self.window.hwnd, id)
 
238
 
 
239
class DoneButtonProcessor(ButtonProcessor):
 
240
    def OnClicked(self, id):
 
241
        getConnAttributes(self.window.manager)
 
242
        self.window.manager.SaveConfig()
 
243
        win32gui.EndDialog(self.window.hwnd, id)
 
244
 
 
245
class MessageProcessor(ControlProcessor):
 
246
    def Init(self):
 
247
        text = "This Outlook Plugin for OpenERP has been developed by TinyERP \n\n \
 
248
                For more information, please visit our website \n \
 
249
                 http://www.openerp.com \n\n \
 
250
                Contact Us \n \
 
251
                sales@tinyerp.com \n\n \
 
252
                2001-TODAY Tiny sprl. All rights reserved. \n"
 
253
        win32gui.SendMessage(self.GetControl(), win32con.WM_SETTEXT, 0, text)
 
254
 
 
255
    def GetPopupHelpText(self, cid):
 
256
        return "Displays details on this plugin"
 
257
 
 
258
class TabProcessor(ControlProcessor):
 
259
    def __init__(self, window, control_ids, page_ids):
 
260
        ControlProcessor.__init__(self, window, control_ids)
 
261
        self.page_ids = page_ids.split()
 
262
 
 
263
    def Init(self):
 
264
        self.pages = {}
 
265
        self.currentPage = None
 
266
        self.currentPageIndex = -1
 
267
        self.currentPageHwnd = None
 
268
        for index, page_id in enumerate(self.page_ids):
 
269
            template = self.window.manager.dialog_parser.dialogs[page_id]
 
270
            self.addPage(index, page_id, template[0][0])
 
271
        server = self.window.manager.config['server']
 
272
        port = self.window.manager.config['port']
 
273
        setConnAttribs(server, port, self.window.manager)
 
274
        self.switchToPage(0)
 
275
 
 
276
    def Done(self):
 
277
        if self.currentPageHwnd is not None:
 
278
            if not self.currentPage.SaveAllControls():
 
279
                win32gui.SendMessage(self.GetControl(), commctrl.TCM_SETCURSEL, self.currentPageIndex,0)
 
280
                return False
 
281
        return True
 
282
 
 
283
    def OnNotify(self, nmhdr, wparam, lparam):
 
284
        selChangedCode =  5177342
 
285
        code = nmhdr[2]
 
286
        if code==selChangedCode:
 
287
            index = win32gui.SendMessage(self.GetControl(), commctrl.TCM_GETCURSEL, 0,0)
 
288
            if index!=self.currentPageIndex:
 
289
                self.switchToPage(index)
 
290
 
 
291
    def switchToPage(self, index):
 
292
        if self.currentPageHwnd is not None:
 
293
            if not self.currentPage.SaveAllControls():
 
294
                win32gui.SendMessage(self.GetControl(), commctrl.TCM_SETCURSEL, self.currentPageIndex,0)
 
295
                return 1
 
296
            win32gui.DestroyWindow(self.currentPageHwnd)
 
297
        self.currentPage = MakePropertyPage(self.GetControl(), self.window.manager, self.window.config, self.pages[index])
 
298
        self.currentPageHwnd = self.currentPage.CreateWindow()
 
299
        self.currentPageIndex = index
 
300
        return 0
 
301
#
 
302
    def addPage(self, item, idName, label):
 
303
        format = "iiiiiii"
 
304
        lbuf = win32gui.PyMakeBuffer(len(label)+1)
 
305
        address,l = win32gui.PyGetBufferAddressAndLen(lbuf)
 
306
        win32gui.PySetString(address, label)
 
307
 
 
308
        buf = struct.pack(format,
 
309
            commctrl.TCIF_TEXT, # mask
 
310
            0, # state
 
311
            0, # state mask
 
312
            address,
 
313
            0, #unused
 
314
            0, #image
 
315
            item
 
316
            )
 
317
        item = win32gui.SendMessage(self.GetControl(),
 
318
                             commctrl.TCM_INSERTITEM,
 
319
                             item,
 
320
                             buf)
 
321
        self.pages[item] = idName
 
322
 
 
323
class DialogCommand(ButtonProcessor):
 
324
    def __init__(self, window, control_ids, idd, func=None, args=()):
 
325
        self.idd = idd
 
326
        self.func = func
 
327
        self.args = args
 
328
        ButtonProcessor.__init__(self, window, control_ids)
 
329
 
 
330
    def OnClicked(self, id):
 
331
        self.id = id
 
332
        if self.func:
 
333
            args = (self, ) + self.args
 
334
            self.func(*args)
 
335
        parent = self.window.hwnd
 
336
        self.window.SaveAllControls()
 
337
        ShowDialog(parent, self.window.manager, self.window.config, self.idd)
 
338
        self.window.LoadAllControls()
 
339
 
 
340
    def GetPopupHelpText(self, id):
 
341
        dd = self.window.manager.dialog_parser.dialogs[self.idd]
 
342
        return "Displays the %s dialog" % dd.caption
 
343
def ReloadAllControls(btnProcessor,*args):
 
344
    server = NewConn._server
 
345
    port = NewConn._port
 
346
    btnProcessor.window.LoadAllControls()
 
347
    if not NewConn._running:
 
348
        win32ui.MessageBox("No server running on host "+ server+" at port "+str(port), "Server Connection", flag_excl)
 
349
    return
 
350
def TestConnection(btnProcessor,*args):
 
351
    server = NewConn._server
 
352
    port = NewConn._port
 
353
    NewConn.GetDBList()
 
354
    if not NewConn._running:
 
355
        btnProcessor.window.LoadAllControls()
 
356
        win32ui.MessageBox("No server running on host "+ server+" at port "+str(port), "Server Connection", flag_excl)
 
357
        return
 
358
    try:
 
359
        dbname = win32gui.GetDlgItemText(btnProcessor.window.hwnd, 7000)
 
360
        if not dbname:
 
361
            win32ui.MessageBox("Please enter database name", "", flag_excl)
 
362
            return
 
363
    except Exception,e:
 
364
        print "Exception %s: %s"%(type(e),str(e))
 
365
    dbname = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
366
    if not dbname:
 
367
        win32ui.MessageBox("No database found on host "+ server+" at port "+str(port), "Database Connection", flag_excl)
 
368
        return
 
369
 
 
370
    uname = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1])
 
371
    pwd = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2])
 
372
 
 
373
    if not uname:
 
374
        win32ui.MessageBox("Enter Username", "", flag_excl)
 
375
        return
 
376
    if not pwd:
 
377
        win32ui.MessageBox("Enter Password", "", flag_excl)
 
378
        return
 
379
 
 
380
    #Establish Connection
 
381
    try:
 
382
        uid = NewConn.login(dbname, uname, pwd)
 
383
        if uid:
 
384
            msg = "Connection Successful"
 
385
            NewConn._login = True
 
386
            NewConn._uname = uname
 
387
            NewConn._pwd = pwd
 
388
            NewConn._uid = uid
 
389
            flag = flag_info
 
390
            if not NewConn.IsCRMInstalled():
 
391
                msg+= '\n\n'+" 'CRM' module is not installed. So CRM cases cannot be created."
 
392
                NewConn._iscrm = False
 
393
            else:
 
394
                try:
 
395
                    list = NewConn.GetCSList()
 
396
                    NewConn._iscrm = True
 
397
                except Exception,e:
 
398
                    msg+= '\n\n'+"CRM cases cannot be created.\n\n" + getMessage(e)
 
399
                    NewConn._iscrm = False
 
400
        else:
 
401
            msg = "Connection Failed. Please check Username or Password"
 
402
            flag = flag_stop
 
403
            NewConn._login = False
 
404
    except Exception,e:
 
405
        msg = "Connection could not be made.\n\n" + getMessage(e)
 
406
        flag = flag_error
 
407
    win32ui.MessageBox(msg, "Database Connection", flag_excl)
 
408
    return
 
409
 
 
410
def BrowseCallbackProc(hwnd, msg, lp, data):
 
411
    from win32com.shell import shell, shellcon
 
412
    if msg== shellcon.BFFM_INITIALIZED:
 
413
        win32gui.SendMessage(hwnd, shellcon.BFFM_SETSELECTION, 1, data)
 
414
        win32gui.SendMessage(hwnd, shellcon.BFFM_ENABLEOK, 0, 0)
 
415
    elif msg == shellcon.BFFM_SELCHANGED:
 
416
        # Set the status text of the
 
417
        # For this message, 'lp' is the address of the PIDL.
 
418
        pidl = shell.AddressAsPIDL(lp)
 
419
        try:
 
420
            path = shell.SHGetPathFromIDList(pidl)
 
421
            if os.path.isdir(path):
 
422
                win32gui.SendMessage(hwnd, shellcon.BFFM_ENABLEOK, 0, 0)
 
423
            else:
 
424
                ext = path.split('.')[-1]
 
425
                if ext not in ['gif', 'bmp', 'jpg', 'tif', 'ico']:
 
426
                        win32gui.SendMessage(hwnd, shellcon.BFFM_ENABLEOK, 0, 0)
 
427
 
 
428
                else:
 
429
                    win32gui.SendMessage(hwnd, shellcon.BFFM_ENABLEOK, 0, 1)
 
430
        except shell.error:
 
431
            # No path for this PIDL
 
432
            pass
 
433
 
 
434
def GetImagePath(btnProcessor,*args):
 
435
    from win32com.shell import shell, shellcon
 
436
    ulFlags = shellcon.BIF_BROWSEINCLUDEFILES | BIF_NEWDIALOGSTYLE | BIF_NONEWFOLDERBUTTON
 
437
    pidl, display_name, image_list=shell.SHBrowseForFolder(btnProcessor.window.hwnd, # parent HWND
 
438
                            None, # root PIDL.
 
439
                            "Get the image path", # title
 
440
                            ulFlags, # flags
 
441
                            BrowseCallbackProc, # callback function
 
442
                            os.getcwd() # 'data' param for the callback
 
443
                            )
 
444
    if (pidl, display_name, image_list) == (None, None, None):
 
445
      return
 
446
    else:
 
447
      path = shell.SHGetPathFromIDList (pidl)
 
448
      win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0], path)
 
449
 
 
450
def AddNewObject(btnProcessor,*args):
 
451
    #Check if server running or user logged in
 
452
    b = check()
 
453
    if not b:
 
454
        return
 
455
 
 
456
    #Check if title or object not specified
 
457
    obj_title = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
458
    obj_name = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1])
 
459
    if not obj_title:
 
460
        win32ui.MessageBox("No Title specified", "", flag_excl)
 
461
        return
 
462
    if not obj_name:
 
463
        win32ui.MessageBox("No object specified", "", flag_excl)
 
464
        return
 
465
 
 
466
    #Check if object does not exist in the database or it already exist in the list
 
467
    try:
 
468
        all_obj_list = NewConn.GetAllObjects()
 
469
        curr_obj_list = [obj[1] for obj in NewConn.GetObjList()]
 
470
        curr_title_list = [obj[0] for obj in NewConn.GetObjList()]
 
471
        if obj_name not in all_obj_list:
 
472
            win32ui.MessageBox("No such object exists", "Object Settings", flag_excl)
 
473
            return
 
474
        elif obj_name in curr_obj_list:
 
475
            win32ui.MessageBox("Object already in the list", "Object Settings", flag_info)
 
476
            return
 
477
        elif obj_title in curr_title_list:
 
478
            win32ui.MessageBox("Title already in the list. Please give different title", "Object Settings", flag_excl)
 
479
            return
 
480
 
 
481
        #extract image path and load the image
 
482
        image_path=''
 
483
        image_path = os.path.join(btnProcessor.window.manager.application_directory, "dialogs\\resources\\openerp_logo1.bmp")
 
484
        path=win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2])
 
485
        if path:
 
486
            image_path = path
 
487
        load_bmp_flags=win32con.LR_LOADFROMFILE | win32con.LR_LOADTRANSPARENT
 
488
        try:
 
489
            hicon = win32gui.LoadImage(0, image_path,win32con.IMAGE_BITMAP, 40, 40, load_bmp_flags)
 
490
        except Exception,e:
 
491
            msg=getMessage(e)
 
492
            hicon=None
 
493
            win32ui.MessageBox(msg, "Load Image", flag_error)
 
494
 
 
495
        #Add the object in the list
 
496
        win32gui.ImageList_Add(il,hicon,0)
 
497
        cnt = win32gui.ImageList_GetImageCount(il)
 
498
 
 
499
        hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[3])
 
500
        num_items = win32gui.SendMessage(hwndList, commctrl.LVM_GETITEMCOUNT)
 
501
 
 
502
        item = LVITEM(text=obj_title, iImage=cnt-2, iItem = num_items)
 
503
        new_index = win32gui.SendMessage(hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam())
 
504
        win32gui.SendMessage(hwndList, commctrl.LVM_SETIMAGELIST, commctrl.LVSIL_SMALL, il)
 
505
        item = LVITEM(text=obj_name, iItem = new_index, iSubItem = 1)
 
506
        win32gui.SendMessage(hwndList, commctrl.LVM_SETITEM, 0, item.toparam())
 
507
 
 
508
        NewConn.InsertObj(obj_title,obj_name,image_path)
 
509
    except Exception, e:
 
510
        msg = "Object not added\n\n" + getMessage(e)
 
511
        win32ui.MessageBox(msg,"",flag_excl)
 
512
        return
 
513
 
 
514
    #Empty all the text controls
 
515
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0], '')
 
516
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1], '')
 
517
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2], '')
 
518
 
 
519
def DeleteSelectedObjects(btnProcessor,*args):
 
520
    #Check if server running or user logged in
 
521
    b = check()
 
522
    if not b:
 
523
        return
 
524
 
 
525
    #Delete selected items
 
526
    hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
527
    sel_count = win32gui.SendMessage(hwndList, commctrl.LVM_GETSELECTEDCOUNT)
 
528
    for i in range(0,sel_count):
 
529
        sel = win32gui.SendMessage(hwndList, commctrl.LVM_GETNEXTITEM, -1, commctrl.LVNI_SELECTED)
 
530
        buf,extra = win32gui_struct.EmptyLVITEM(1, 0)
 
531
        r = win32gui.SendMessage(hwndList, commctrl.LVM_GETITEMTEXT, sel, buf)
 
532
        sel_text = ''
 
533
        for n in extra:
 
534
            nombre = n.tostring()
 
535
            sel_text = nombre[0:r]
 
536
        s = win32gui.SendMessage(hwndList, commctrl.LVM_DELETEITEM, sel)
 
537
        try:
 
538
            NewConn.DeleteObject(sel_text)
 
539
        except Exception,e:
 
540
            msg = "Object '%s' not deleted\n\n"%sel_text + getMessage(e)
 
541
            win32ui.MessageBox(msg,"",flag_excl)
 
542
 
 
543
def GetMail(processor):
 
544
    ex = processor.window.manager.outlook.ActiveExplorer()
 
545
    assert ex.Selection.Count == 1
 
546
    mail = ex.Selection.Item(1)
 
547
    return mail
 
548
 
 
549
#get selected records from list
 
550
def GetSelectedItems(hwndList):
 
551
    r=[]
 
552
    sel_count = win32gui.SendMessage(hwndList, commctrl.LVM_GETSELECTEDCOUNT)
 
553
    sel=-1
 
554
    for i in range(0,sel_count):
 
555
        sel = win32gui.SendMessage(hwndList, commctrl.LVM_GETNEXTITEM, sel, commctrl.LVNI_SELECTED)
 
556
        buf,extra = win32gui_struct.EmptyLVITEM(1, 0)
 
557
        size = win32gui.SendMessage(hwndList, commctrl.LVM_GETITEMTEXT, sel, buf)
 
558
        sel_text = ''
 
559
        for n in extra:
 
560
            nombre = n.tostring()
 
561
            sel_text = nombre[0:size]
 
562
        for item in objects_with_match:
 
563
            if item[2] == sel_text:
 
564
                 r.append(item)
 
565
    return r
 
566
 
 
567
def MakeAttachment(btnProcessor,*args):
 
568
    #Check if server running or user logged in
 
569
    b = check()
 
570
    if not b:
 
571
        return
 
572
 
 
573
    ex = btnProcessor.window.manager.outlook.ActiveExplorer()
 
574
    assert ex.Selection.Count == 1
 
575
    mail = ex.Selection.Item(1)
 
576
    mail = GetMail(btnProcessor)
 
577
 
 
578
    #get selected records
 
579
    hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
580
    r = GetSelectedItems(hwndList)
 
581
    if not r:
 
582
        win32ui.MessageBox("No records selected", "Make Attachment", flag_info)
 
583
        return
 
584
 
 
585
    try:
 
586
        NewConn.ArchiveToOpenERP(r,mail)
 
587
        msg="Mail archived to OpenERP."
 
588
        flag = flag_info
 
589
    except Exception,e:
 
590
        msg = "Attachment not created \n\n" + getMessage(e)
 
591
        flag = flag_error
 
592
    win32ui.MessageBox(msg, "Make Attachment", flag)
 
593
    return
 
594
 
 
595
 
 
596
def CreateCase(btnProcessor,*args):
 
597
    #Check if server running or user logged in
 
598
    b = check()
 
599
    if not b:
 
600
        return
 
601
 
 
602
    if NewConn._iscrm:
 
603
    #    Get the selected mail
 
604
        ex = btnProcessor.window.manager.outlook.ActiveExplorer()
 
605
        assert ex.Selection.Count == 1
 
606
        mail = ex.Selection.Item(1)
 
607
        section = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
608
 
 
609
        if not section:
 
610
            win32ui.MessageBox("CRM Case could not be created. No CRM Sections found. Please configure database first.", "Create Case", flag_excl)
 
611
            return
 
612
 
 
613
        hwndList = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[1])
 
614
        partner_ids=[]
 
615
        r = GetSelectedItems(hwndList)
 
616
        for rec in r:
 
617
            if rec[0] == 'res.partner':
 
618
                partner_ids.append(rec[1])
 
619
 
 
620
        #Create new case
 
621
        try:
 
622
            NewConn.CreateCase(section, mail, partner_ids)
 
623
            msg="New case created."
 
624
            flag=flag_info
 
625
        except Exception,e:
 
626
            msg="CRM Case not created \n\n"+getMessage(e)
 
627
            flag=flag_error
 
628
        win32ui.MessageBox(msg, "Create Case", flag)
 
629
        return
 
630
    else:
 
631
        win32ui.MessageBox("CRM Cases can not be created.", "Create Case", flag_info)
 
632
 
 
633
def GetSearchText(txtProcessor,*args):
 
634
    #Check if server running or user logged in
 
635
    b = check()
 
636
    if not b:
 
637
        return
 
638
 
 
639
    search_box = txtProcessor.GetControl()
 
640
    global search_text
 
641
    if txtProcessor.init_done:
 
642
        win32gui.SendMessage(search_box, win32con.WM_SETTEXT, 0,search_text)
 
643
        return
 
644
 
 
645
    # Get the selected mail and set the default value for search_text_control to mail.SenderEmailAddress
 
646
    ex = txtProcessor.window.manager.outlook.ActiveExplorer()
 
647
    assert ex.Selection.Count == 1
 
648
    mail = ex.Selection.Item(1)
 
649
    try:
 
650
        search_text = str(mail.SenderEmailAddress)
 
651
    except Exception,e:
 
652
        pass
 
653
    win32gui.SendMessage(search_box, win32con.WM_SETTEXT, 0, search_text)
 
654
    txtProcessor.init_done=True
 
655
 
 
656
def SetNameColumn(listProcessor,*args):
 
657
    hwndList = listProcessor.GetControl()
 
658
    child_ex_style = win32gui.SendMessage(hwndList, commctrl.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
 
659
    child_ex_style |= commctrl.LVS_EX_FULLROWSELECT
 
660
    win32gui.SendMessage(hwndList, commctrl.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, child_ex_style)
 
661
 
 
662
    # set header row
 
663
    lvc =  LVCOLUMN(
 
664
                    mask = commctrl.LVCF_FMT | commctrl.LVCF_WIDTH | \
 
665
                    commctrl.LVCF_TEXT | commctrl.LVCF_SUBITEM
 
666
                    )
 
667
    lvc.fmt = commctrl.LVCFMT_LEFT
 
668
    lvc.iSubItem = 0
 
669
    lvc.text = "Name"
 
670
    lvc.cx = 424
 
671
    win32gui.SendMessage(hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
 
672
    listProcessor.init_done = True
 
673
 
 
674
def setList(list_hwnd):
 
675
    # Set default list of objects
 
676
    win32gui.SendMessage(list_hwnd, commctrl.LVM_DELETEALLITEMS)
 
677
    for obj in objects_with_match:
 
678
        num_items = win32gui.SendMessage(list_hwnd, commctrl.LVM_GETITEMCOUNT)
 
679
        item = LVITEM(text=obj[2],iItem = num_items)
 
680
        win32gui.SendMessage(list_hwnd, commctrl.LVM_INSERTITEM, 0, item.toparam())
 
681
 
 
682
def SearchObjectsForText(btnProcessor,*args):
 
683
    #Check if server running or user logged in
 
684
    b = check()
 
685
    if not b:
 
686
        return
 
687
 
 
688
    search_txt = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
689
    if not search_txt:
 
690
        win32ui.MessageBox("Enter text to search for", "", flag_info)
 
691
        return
 
692
    # Get titles from list
 
693
    obj_titles=[]
 
694
    for ch in hwndChk_list:
 
695
        id = ch[0]
 
696
        hwnd = ch[1]
 
697
        chk = win32gui.SendMessage(hwnd, win32con.BM_GETCHECK)
 
698
        if chk:
 
699
            txt = win32gui.GetDlgItemText(btnProcessor.window.hwnd,id)
 
700
            obj_titles.append(txt)
 
701
 
 
702
    # Prepare list of objects to search for the seach_keyword
 
703
    obj_list = btnProcessor.window.manager.config['objects']
 
704
    search_list = []
 
705
    try:
 
706
        all_obj_list = NewConn.GetAllObjects()
 
707
        for title in obj_titles:
 
708
            objname = [obj[1] for obj in obj_list if obj[0] == title]
 
709
            if objname:
 
710
                assert len(objname) == 1
 
711
                if objname[0] in all_obj_list:
 
712
                     search_list.append(objname[0])
 
713
                else:
 
714
                    win32ui.MessageBox("Module %s (%s) not installed. Please install it." \
 
715
                                       %(title,objname[0]), "", flag_excl)
 
716
                    return
 
717
 
 
718
        #  Get the records by searching the objects in search_list for the search_keyword as objects_with_match
 
719
        global objects_with_match
 
720
        list_hwnd = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[1])
 
721
        if search_list:
 
722
            objects_with_match = NewConn.GetObjectItems(search_list, search_txt)
 
723
            if not objects_with_match:
 
724
                win32ui.MessageBox("No matching records found in checked objects", "", flag_info)
 
725
        else:
 
726
            win32ui.MessageBox("No object selected", "", flag_info)
 
727
            objects_with_match=[]
 
728
        # Display the objects_with_match records in list
 
729
        setList(list_hwnd)
 
730
    except Exception,e:
 
731
        msg=getMessage(e)
 
732
        win32ui.MessageBox(msg, "", flag_error)
 
733
 
 
734
def CreateContact(btnProcessor,*args):
 
735
    b = check()
 
736
    if not b:
 
737
        return
 
738
 
 
739
    partner = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[4])
 
740
    combo = win32gui.GetDlgItem(btnProcessor.window.hwnd, btnProcessor.other_ids[4])
 
741
    sel = win32gui.SendMessage(combo, win32con.CB_GETCURSEL)
 
742
 
 
743
    name = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
744
    email = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1])
 
745
    office_no = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2])
 
746
    mobile_no = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[3])
 
747
 
 
748
    if not name:
 
749
        win32ui.MessageBox("Please enter name.", "Create Contact", flag_stop)
 
750
        return
 
751
    res = {'name':name, 'email':email, 'phone':office_no, 'mobile':mobile_no}
 
752
    try:
 
753
        id = NewConn.CreateContact(sel, res)
 
754
        msg="New contact created for partner '%s'."%partner
 
755
    except Exception,e:
 
756
        msg="Contact not created \n\n" + getMessage(e)
 
757
        win32ui.MessageBox(msg, "Create Contact", flag_error)
 
758
        return
 
759
 
 
760
    win32ui.MessageBox(msg, "Create Contact", flag_info)
 
761
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0], '')
 
762
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[1], '')
 
763
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[2], '')
 
764
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[3], '')
 
765
 
 
766
def SetAllText(txtProcessor,*args):
 
767
    # Set values for url, uname, pwd from config file
 
768
    url = NewConn._uri
 
769
    tbox = txtProcessor.GetControl()
 
770
    win32gui.SendMessage(tbox, win32con.WM_SETTEXT, 0, url)
 
771
 
 
772
    uname = NewConn._uname
 
773
    tbox = txtProcessor.GetControl(txtProcessor.other_ids[0])
 
774
    win32gui.SendMessage(tbox, win32con.WM_SETTEXT, 0, uname)
 
775
 
 
776
def SetDefaultList(listProcessor,*args):
 
777
    hwndList = listProcessor.GetControl()
 
778
 
 
779
    # set full row select style
 
780
    child_ex_style = win32gui.SendMessage(hwndList, commctrl.LVM_GETEXTENDEDLISTVIEWSTYLE, 0, 0)
 
781
    child_ex_style |= commctrl.LVS_EX_FULLROWSELECT
 
782
    win32gui.SendMessage(hwndList, commctrl.LVM_SETEXTENDEDLISTVIEWSTYLE, 0, child_ex_style)
 
783
 
 
784
    # set header row
 
785
    lvc =  LVCOLUMN(
 
786
                    mask = commctrl.LVCF_FMT | commctrl.LVCF_WIDTH | \
 
787
                    commctrl.LVCF_TEXT | commctrl.LVCF_SUBITEM
 
788
                    )
 
789
    lvc.fmt = commctrl.LVCFMT_LEFT
 
790
    lvc.iSubItem = 1
 
791
    lvc.text = "Object Name"
 
792
    lvc.cx = 275
 
793
    win32gui.SendMessage(hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
 
794
    lvc.iSubItem = 0
 
795
    lvc.text = "Title"
 
796
    lvc.cx = 275
 
797
    win32gui.SendMessage(hwndList, commctrl.LVM_INSERTCOLUMN, 0, lvc.toparam())
 
798
 
 
799
    #create imagelist
 
800
    global il
 
801
    il = win32gui.ImageList_Create(
 
802
                        win32api.GetSystemMetrics(win32con.SM_CXSMICON),
 
803
                        win32api.GetSystemMetrics(win32con.SM_CYSMICON),
 
804
                        commctrl.ILC_COLOR32 | commctrl.ILC_MASK,
 
805
                        1, # initial size
 
806
                        0) # cGrow
 
807
 
 
808
    win32gui.SendMessage(hwndList, commctrl.LVM_SETIMAGELIST,\
 
809
                                 commctrl.LVSIL_SMALL, il)
 
810
    # Set objects from config
 
811
    objs = NewConn._obj_list
 
812
    load_bmp_flags=win32con.LR_LOADFROMFILE | win32con.LR_LOADTRANSPARENT
 
813
    for obj in objs:
 
814
        image_path = os.path.join(listProcessor.window.manager.application_directory, "dialogs\\resources\\openerp_logo1.bmp")
 
815
        path=obj[2]
 
816
        if path:
 
817
            image_path = path
 
818
        try:
 
819
            hicon = win32gui.LoadImage(0, image_path,win32con.IMAGE_BITMAP, 40, 40, load_bmp_flags)
 
820
        except Exception, e:
 
821
            msg = "Problem loading the image \n\n" + getMessage(e)
 
822
            hicon = None
 
823
            win32ui.MessageBox(msg, "Load Image", flag_error)
 
824
 
 
825
        #Add the object in the list
 
826
        win32gui.ImageList_Add(il,hicon,0)
 
827
        cnt = win32gui.ImageList_GetImageCount(il)
 
828
        num_items = win32gui.SendMessage(hwndList, commctrl.LVM_GETITEMCOUNT)
 
829
        item = LVITEM(text=obj[0],iImage=cnt-2, iItem = num_items)
 
830
        new_index = win32gui.SendMessage(hwndList, commctrl.LVM_INSERTITEM, 0, item.toparam())
 
831
        item = LVITEM(text=obj[1], iItem = new_index, iSubItem = 1)
 
832
        win32gui.SendMessage(hwndList, commctrl.LVM_SETITEM, 0, item.toparam())
 
833
 
 
834
def SetDefaultContact(txtProcessor,*args):
 
835
    txt_name = txtProcessor.GetControl()
 
836
    txt_email = txtProcessor.GetControl(txtProcessor.other_ids[0])
 
837
 
 
838
    global name
 
839
    global email
 
840
    if txtProcessor.init_done:
 
841
        win32gui.SetDlgItemText(txtProcessor.window.hwnd, txtProcessor.control_id,name)
 
842
        win32gui.SetDlgItemText(txtProcessor.window.hwnd, txtProcessor.other_ids[0],email)
 
843
        return
 
844
 
 
845
    try:
 
846
        mail = GetMail(txtProcessor)
 
847
        name = mail.SenderName
 
848
        email = mail.SenderEmailAddress
 
849
    except Exception,e:
 
850
        pass
 
851
 
 
852
    win32gui.SetDlgItemText(txtProcessor.window.hwnd, txtProcessor.control_id,name)
 
853
    win32gui.SetDlgItemText(txtProcessor.window.hwnd, txtProcessor.other_ids[0],email)
 
854
    txtProcessor.init_done = True
 
855
 
 
856
# Set objects from config
 
857
def setCheckList(groupProcessor,*args):
 
858
    child_style = win32con.BS_AUTOCHECKBOX | win32con.WS_TABSTOP
 
859
    hinst = win32gui.dllhandle
 
860
    objs = groupProcessor.window.manager.config['objects']
 
861
    left = 20
 
862
    top = 50
 
863
    cnt=0
 
864
    id=4001
 
865
    id1=6001
 
866
    load_bmp_flags=win32con.LR_LOADFROMFILE | win32con.LR_LOADTRANSPARENT
 
867
    if groupProcessor.init_done:
 
868
        return
 
869
    else:
 
870
        for obj in objs:
 
871
            groupProcessor.init_done = True
 
872
            #Add image
 
873
            hwndImg = win32gui.CreateWindowEx(0, "STATIC","",
 
874
                                        win32con.SS_CENTERIMAGE | win32con.SS_REALSIZEIMAGE | win32con.SS_BITMAP | win32con.WS_CHILD | win32con.WS_VISIBLE,
 
875
                                        left,top+3,13,13,
 
876
                                        groupProcessor.window.hwnd,
 
877
                                        id,
 
878
                                        0,
 
879
                                        None
 
880
                                        );
 
881
            image_path = os.path.join(groupProcessor.window.manager.application_directory, "dialogs\\resources\\openerp_logo1.bmp")
 
882
            if obj[2]:
 
883
                image_path = obj[2]
 
884
            try:
 
885
                hicon = win32gui.LoadImage(0, image_path, win32con.IMAGE_BITMAP, 40, 40, load_bmp_flags)
 
886
            except Exception,e:
 
887
                msg="Problem loading the image \n\n" + getMessage(e)
 
888
                hicon = None
 
889
                win32ui.MessageBox(msg, "Load Image", flag_error)
 
890
 
 
891
            win32gui.SendMessage(hwndImg, win32con.STM_SETIMAGE, win32con.IMAGE_BITMAP, hicon);
 
892
 
 
893
            #Add Checkbox
 
894
            left+= 17
 
895
            hwndChk = win32gui.CreateWindowEx(
 
896
                                                0,"BUTTON",obj[0],win32con.WS_VISIBLE | win32con.WS_CHILD | \
 
897
                                                win32con.BS_AUTOCHECKBOX | win32con.WS_TABSTOP | win32con.BST_CHECKED, \
 
898
                                                left, top, 130,20,groupProcessor.window.hwnd,id1,hinst,None
 
899
                                              )
 
900
            if obj[1] in ['res.partner','res.partner.address']:
 
901
                win32gui.SendMessage(hwndChk , win32con.BM_SETCHECK, 1, 0);
 
902
            hwndChk_list.append((id1,hwndChk))
 
903
 
 
904
            cnt=cnt+1
 
905
            id+=1
 
906
            id1+=1
 
907
            top+=17
 
908
            win32gui.UpdateWindow(hwndImg)
 
909
            left-=17
 
910
            if cnt > 8:
 
911
                left+=150
 
912
                top = 50
 
913
                cnt=0
 
914
 
 
915
def CreatePartner(btnProcessor,*args):
 
916
    #Check if server running or user logged in
 
917
    b = check()
 
918
    if not b:
 
919
        return
 
920
 
 
921
    partner_name = win32gui.GetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0])
 
922
    if not partner_name:
 
923
        win32ui.MessageBox("Please enter Partner name.", "Create Partner", flag_excl)
 
924
        return
 
925
    res = {'name':partner_name}
 
926
    try:
 
927
        id = NewConn.CreatePartner(res)
 
928
    except Exception,e:
 
929
        msg="Partner not created \n\n" + getMessage(e)
 
930
        win32ui.MessageBox(msg, "Create Partner", flag_error)
 
931
        return
 
932
    if id:
 
933
        win32ui.MessageBox("New Partner '%s' created."%partner_name, "Create Partner", flag_info)
 
934
        win32gui.EndDialog(btnProcessor.window.hwnd, btnProcessor.id)
 
935
    else:
 
936
        win32ui.MessageBox("Partner '%s' already Exists."%partner_name, "Create Partner", flag_info)
 
937
    win32gui.SetDlgItemText(btnProcessor.window.hwnd, btnProcessor.other_ids[0],'')
 
938
 
 
939
def set_search_text(dialogProcessor,*args):
 
940
    global search_text
 
941
    search_text = win32gui.GetDlgItemText(dialogProcessor.window.hwnd, dialogProcessor.other_ids[0])
 
942
    return
 
943
 
 
944
def set_name_email(dialogProcessor,*args):
 
945
    global name
 
946
    global email
 
947
    name = win32gui.GetDlgItemText(dialogProcessor.window.hwnd, dialogProcessor.other_ids[0])
 
948
    email = win32gui.GetDlgItemText(dialogProcessor.window.hwnd, dialogProcessor.other_ids[1])
 
949
 
 
950
dialog_map = {
 
951
            "IDD_MANAGER" :            (
 
952
                (CancelButtonProcessor,    "IDCANCEL", resetConnAttribs, ()),
 
953
                (TabProcessor,             "IDC_TAB IDC_LIST",
 
954
                                           """IDD_GENERAL IDD_OBJECT_SETTINGS IDD_ABOUT"""),
 
955
                (DoneButtonProcessor,      "ID_DONE"),
 
956
            ),
 
957
 
 
958
            "IDD_GENERAL":             (
 
959
                (DBComboProcessor,          "ID_DB_DROPDOWNLIST", GetConn, ()),
 
960
                (TextProcessor,             "ID_SERVER_PORT ID_USERNAME ID_PASSWORD", SetAllText, ()),
 
961
                (CommandButtonProcessor,    "ID_BUT_TESTCONNECTION ID_DB_DROPDOWNLIST ID_USERNAME \
 
962
                                            ID_PASSWORD", TestConnection, ()),
 
963
                (CommandButtonProcessor,    "IDC_RELOAD", ReloadAllControls, ()),
 
964
                (DialogCommand,             "IDC_BUT_SET_SERVER_PORT", "IDD_SERVER_PORT_DIALOG"),
 
965
            ),
 
966
 
 
967
            "IDD_OBJECT_SETTINGS" :    (
 
968
                (CommandButtonProcessor,   "IDC_BUT_LOAD_IMAGE IDC_IMAGE_PATH", GetImagePath, ()),
 
969
                (CommandButtonProcessor,   "IDC_BUT_SAVE_OBJECT IDC_OBJECT_TITLE IDC_OBJECT_NAME \
 
970
                                            IDC_IMAGE_PATH IDC_LIST", AddNewObject, ()),
 
971
                (CommandButtonProcessor,   "IDC_BUT_DEL_OBJECT IDC_LIST", DeleteSelectedObjects, ()),
 
972
                (ListBoxProcessor,         "IDC_LIST", SetDefaultList, ())
 
973
            ),
 
974
 
 
975
            "IDD_ABOUT" :              (
 
976
                (ImageProcessor,          "IDB_OPENERPLOGO"),
 
977
                (MessageProcessor,        "IDC_ABOUT"),
 
978
            ),
 
979
 
 
980
            "IDD_SERVER_PORT_DIALOG" : (
 
981
                (CloseButtonProcessor,    "IDCANCEL"),
 
982
                (OKButtonProcessor,  "IDOK ID_SERVER ID_PORT"),
 
983
            ),
 
984
 
 
985
            "IDD_SYNC" :               (
 
986
                (CommandButtonProcessor,    "ID_SEARCH ID_SEARCH_TEXT IDC_NAME_LIST", SearchObjectsForText,()),
 
987
                (GroupProcessor,             "IDC_STATIC_GROUP", setCheckList, ()),
 
988
                (CSComboProcessor,          "ID_ATT_METHOD_DROPDOWNLIST", GetConn,()),
 
989
                (TextProcessor,             "ID_SEARCH_TEXT", GetSearchText, ()),
 
990
                (DialogCommand,             "ID_CREATE_CONTACT ID_SEARCH_TEXT", "IDD_NEW_CONTACT_DIALOG", set_search_text, ()),
 
991
                (CloseButtonProcessor,      "IDCANCEL"),
 
992
                (CommandButtonProcessor,    "ID_MAKE_ATTACHMENT IDC_NAME_LIST", MakeAttachment, ()),
 
993
                (CommandButtonProcessor,    "ID_CREATE_CASE ID_ATT_METHOD_DROPDOWNLIST IDC_NAME_LIST", CreateCase, ()),
 
994
                (ListBoxProcessor,         "IDC_NAME_LIST", SetNameColumn, ())
 
995
            ),
 
996
 
 
997
            "IDD_NEW_CONTACT_DIALOG" : (
 
998
                (PartnersComboProcessor,    "ID_PARTNER_DROPDOWNLIST", GetConn, ()),
 
999
                (CloseButtonProcessor,      "IDCANCEL"),
 
1000
                (CommandButtonProcessor,    "ID_CONTACT_SAVE_BUTTON ID_CONTACT_NAME_TEXT ID_CONTACT_EMAIL_TEXT ID_CONTACT_OFFICE_TEXT ID_CONTACT_MOBILE_TEXT ID_PARTNER_DROPDOWNLIST", CreateContact, ()),
 
1001
                (TextProcessor,             "ID_CONTACT_NAME_TEXT ID_CONTACT_EMAIL_TEXT", SetDefaultContact, ()),
 
1002
                (DialogCommand,             "ID_NEW_PARTNER_BUTTON ID_CONTACT_NAME_TEXT ID_CONTACT_EMAIL_TEXT", "IDD_NEW_PARTNER_DIALOG", set_name_email, ()),
 
1003
            ),
 
1004
 
 
1005
            "IDD_NEW_PARTNER_DIALOG" : (
 
1006
                (CloseButtonProcessor,      "IDCANCEL"),
 
1007
                (CommandButtonProcessor,    "ID_SAVE_PARTNER_BUTTON ID_PARTNER_NAME_TEXT", CreatePartner, ()),
 
1008
            ),
 
1009
}