Commit 53605902a0d842cb04c1f9378844e3afec33db8e
- Diff rendering mode:
- inline
- side by side
webactivity.py
(2 / 41)
  | |||
85 | 85 | cookie_data = {'color': profile.get_color().to_string(), | |
86 | 86 | 'pkey_hash': sha1.new(pubkey).hexdigest()} | |
87 | 87 | ||
88 | db_path = os.path.join(_profile_path, 'cookies.sqlite') | ||
89 | try: | ||
90 | cookies_db = sqlite3.connect(db_path) | ||
91 | c = cookies_db.cursor() | ||
88 | # TODO set cookie for webkit | ||
92 | 89 | ||
93 | c.execute('''CREATE TABLE IF NOT EXISTS | ||
94 | moz_cookies | ||
95 | (id INTEGER PRIMARY KEY, | ||
96 | name TEXT, | ||
97 | value TEXT, | ||
98 | host TEXT, | ||
99 | path TEXT, | ||
100 | expiry INTEGER, | ||
101 | lastAccessed INTEGER, | ||
102 | isSecure INTEGER, | ||
103 | isHttpOnly INTEGER)''') | ||
104 | |||
105 | c.execute('''SELECT id | ||
106 | FROM moz_cookies | ||
107 | WHERE name=? AND host=? AND path=?''', | ||
108 | ('xoid', jabber_server, '/')) | ||
109 | |||
110 | if c.fetchone(): | ||
111 | _logger.debug('seed_xs_cookie: Cookie exists already') | ||
112 | return | ||
113 | |||
114 | expire = int(time.time()) + 10*365*24*60*60 | ||
115 | c.execute('''INSERT INTO moz_cookies (name, value, host, | ||
116 | path, expiry, lastAccessed, | ||
117 | isSecure, isHttpOnly) | ||
118 | VALUES(?,?,?,?,?,?,?,?)''', | ||
119 | ('xoid', cjson.encode(cookie_data), jabber_server, | ||
120 | '/', expire, 0, 0, 0 )) | ||
121 | cookies_db.commit() | ||
122 | cookies_db.close() | ||
123 | except sqlite3.Error, e: | ||
124 | _logger.error('seed_xs_cookie: %s' % e) | ||
125 | else: | ||
126 | _logger.debug('seed_xs_cookie: Updated cookie successfully') | ||
127 | |||
128 | |||
129 | #TODO set app version and profile path | ||
90 | #TODO set app version? and profile path | ||
130 | 91 | ||
131 | 92 | def _set_accept_languages(): | |
132 | 93 | ''' Set intl.accept_languages based on the locale |