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