]> de.git.xonotic.org Git - xonotic/netradiant.git/blob - setup/win32/msi.py
- UFO:Alien Invasion Plugin (mattn2)
[xonotic/netradiant.git] / setup / win32 / msi.py
1 # Copyright (C) 2001-2006 William Joseph.
2
3 # This file is part of GtkRadiant.
4
5 # GtkRadiant is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2 of the License, or
8 # (at your option) any later version.
9
10 # GtkRadiant is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with GtkRadiant; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
19
20 import msiquery
21
22 class Record:
23   def __init__(self, record):
24     self.record = record
25     
26   def setstring(self, index, string):
27     self.record.setstring(index, string)
28
29 class View:
30   def __init__(self, view):
31     self.view = view
32     
33   def fetch(self):
34     record = self.view.fetch()
35     if(record == None):
36       raise Exception("no records available")
37     return Record(record)
38     
39   def update(self, record):
40     self.view.update(record.record)
41
42 class Database:
43   def __init__(self, name):
44     self.msiDB = msiquery.MsiDB(name)
45
46   def commit(self):
47     result = self.msiDB.commit()
48     if(result != 0):
49       raise Exception("msi commit failed: error " + str(result))
50     
51   def openview(self, query):
52     view = self.msiDB.openview(query)
53     if(view == None):
54       raise Exception("msi openview failed")
55     return View(view);
56
57   def setproperty(self, propertyName, propertyValue):
58     query = "UPDATE `Property` SET `Property`.`Value`='" + propertyValue + "' WHERE `Property`.`Property`='" + propertyName + "'" 
59     self.openview(query)
60
61   def setlicense(self, rtfString):
62     view = self.openview("SELECT `Control`.`Text` FROM `Control` WHERE `Control`.`Control`='AgreementText'")
63     record = view.fetch();
64     record.setstring(1, rtfString)
65     view.update(record)
66