home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.5)
-
- from __future__ import with_statement
- from threads import Timer, threaded
- from primitives import traceguard
- import stdpaths
- import traceback
- from logging import getLogger
- log = getLogger('check_ffx_prefs')
- DIGSBY_SEARCH_URL = 'http://searchbox.digsby.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t'
- CHECK_INTERVAL = 300
- SEARCH_LINES = [
- 'user_pref("browser.search.defaultenginename", "Google Powered Digsby Search");',
- 'user_pref("keyword.URL", "http://searchbox.digsby.com/search?sourceid=navclient&gfns=1&q=");']
- HOMEPAGE_LINES = [
- 'user_pref("browser.startup.homepage", "http://search.digsby.com");']
- DIGSBY_SEARCH_UUID_IE = '{3326ab56-742e-5603-906f-290517220122}'
- SEARCH_PLUGIN_TXT = '<?xml version="1.0" encoding="UTF-8"?>\n<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"\n xmlns:moz="http://www.mozilla.org/2006/browser/search/">\n <ShortName>Google Powered Digsby Search</ShortName>\n <Description>Google Powered Digsby Search</Description>\n <InputEncoding>UTF-8</InputEncoding>\n <moz:UpdateUrl>http://digsby.com/digsbysearch.xml</moz:UpdateUrl>\n <moz:UpdateInterval>7</moz:UpdateInterval>\n <Image width="16" height="16">data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAaRJREFUeNpiVIg5JRURw0A0YAHio943kYV%2B%2Ff33%2BdvvX7%2F%2FMjEx8nKycrGzwKXOiPKzICvdeezLhCV3jp15%2Bfv%2FX0YGhv8MDDxMX2qKTIw0RK10eYD6QYqATvoPBkt3f5K0W9Ew4fjTFz%2F%2Bw8Dm3W8UPeZxqFa%2BevsFyD0twgfVsOfkRxHrtfV9u5BVQ8Crd98%2FffkGYQM1QJ20%2FfSPv79eNxQGYfpSVJADmcvEAHbr7oOX2dj%2FERNKIA2%2F%2F%2Fz%2FxfCDhYVoDUDw5P6vf9%2B5iY0HVmZGQWm%2BN3fff%2Fn2k4eLHS739x%2FDiRs%2Ff%2F%2F5x8HO%2FOHzN3djfqgNjIwMgc6qzLx%2Fpy47j2zY%2Feff06tXhOUucgxeun33AUZGpHh4%2Bvo7t8EyIJqz%2FhpasD59%2B5dNrqdnznZIsEL9ICXCsWuBCwvTv%2FymS5PWPP32ExEALz%2F%2BB5r848cPCJcRaMP9xaYQzofPPzfuvrnj0Jst%2B5%2F8%2Bc4sLPeDkYlRgJc93VPE18NIXkYUmJYQSQMZ%2FP3379uPH7%2F%2F%2FEETBzqJ0WqLGvFpe2LCC4AAAwAyjg7ENzDDWAAAAABJRU5ErkJggg%3D%3D</Image>\n <Url type="text/html" method="GET" template="http://searchbox.digsby.com/search?q={searchTerms}&ie=utf-8&oe=utf-8&aq=t" />\n <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&client=firefox&hl={moz:locale}&q={searchTerms}" />\n <moz:SearchForm>http://searchbox.digsby.com</moz:SearchForm>\n</OpenSearchDescription>'
- FFX_EXE = 'firefox.exe'
-
- def start_checking():
- log.info('starting checker')
- Timer(0, do_check).start()
-
-
- def set_search_active():
-
- try:
- AddGoogleSearchEngine_IE()
- except Exception:
- traceback.print_exc()
-
-
- try:
-
- try:
- f = _[2]
- f.write(' ')
- finally:
- pass
-
- except Exception:
- traceback.print_exc()
- return False
-
- return True
-
-
- def set_homepage_active():
-
- try:
- AddGoogleHomePage_IE()
- except Exception:
- traceback.print_exc()
-
-
- try:
-
- try:
- f = _[2]
- f.write(' ')
- finally:
- pass
-
- except Exception:
- traceback.print_exc()
- return False
-
- return True
-
-
- def _get_search_filepath():
- return stdpaths.userdata / 'dosearch'
-
-
- def _get_homepage_filepath():
- return stdpaths.userdata / 'dohomepage'
-
-
- def do_check():
- search = _get_search_filepath()
- homepage = _get_homepage_filepath()
- if search.exists():
- pass
- dosearch = search.isfile()
- if homepage.exists():
- pass
- dohomepage = homepage.isfile()
- log.info('dosearch: %s, dohomepage: %s', dosearch, dohomepage)
- if dosearch or dohomepage:
- if is_ffx_running():
- log.info('ffx was running, checking again in %d seconds', CHECK_INTERVAL)
- Timer(CHECK_INTERVAL, do_check).start()
- else:
- log.info('ffx not running, attempting to write prefs')
- do_write(dosearch, dohomepage)
-
-
- do_check = threaded(do_check)
-
- def do_write(search, homepage):
- search_pth = _get_search_filepath()
- homepage_pth = _get_homepage_filepath()
- for pth in (stdpaths.userconfig / 'Mozilla' / 'Firefox' / 'Profiles').dirs():
- searchplugins = pth / 'searchplugins'
- if not searchplugins.exists():
- traceguard.__enter__()
-
- try:
- searchplugins.makedirs()
- finally:
- pass
-
-
- if searchplugins.exists() and searchplugins.isdir():
-
- try:
- f = _[3]
- f.write(SEARCH_PLUGIN_TXT)
- finally:
- pass
-
-
- profileprefs = pth / 'prefs.js'
- if profileprefs.exists() and profileprefs.isfile():
- traceguard.__enter__()
-
- try:
-
- try:
- f = _[6]
- if homepage:
- log.info('writing homepage prefs')
- traceguard.__enter__()
-
- try:
- f.writelines(HOMEPAGE_LINES)
- finally:
- pass
-
- traceguard.__enter__()
-
- try:
- homepage_pth.remove()
- finally:
- pass
-
- finally:
- pass
-
- finally:
- pass
-
- continue
- traceguard
-
-
- do_write = threaded(do_write)
-
- def AddGoogleHomePage_IE():
- import _winreg
- traceguard.__enter__()
-
- try:
- k = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Internet Explorer\\Main\\', 0, _winreg.KEY_SET_VALUE)
- _winreg.SetValueEx(k, 'Start Page', None, _winreg.REG_SZ, 'http://search.digsby.com')
- k.Close()
- finally:
- pass
-
-
-
- def AddGoogleSearchEngine_IE():
- import _winreg
- traceguard.__enter__()
-
- try:
- k = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Internet Explorer\\SearchScopes\\', 0, _winreg.KEY_ALL_ACCESS)
- _winreg.SetValueEx(k, 'DefaultScope', None, _winreg.REG_SZ, DIGSBY_SEARCH_UUID_IE)
- k2 = _winreg.CreateKey(k, DIGSBY_SEARCH_UUID_IE)
- _winreg.SetValueEx(k2, 'DisplayName', None, _winreg.REG_SZ, 'Google Powered Digsby Search')
- _winreg.SetValueEx(k2, 'URL', None, _winreg.REG_SZ, DIGSBY_SEARCH_URL)
- k3 = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Internet Explorer\\Main', 0, _winreg.KEY_ALL_ACCESS)
- k4 = _winreg.CreateKey(k3, 'Main')
- _winreg.SetValueEx(k4, 'Use Search Asst', None, _winreg.REG_SZ, 'no')
- _winreg.SetValueEx(k4, 'Search Page', None, _winreg.REG_SZ, 'http://searchbox.digsby.com/')
- _winreg.SetValueEx(k4, 'Search Bar', None, _winreg.REG_SZ, 'http://searchbox.digsby.com/ie')
- k.Close()
- k2.Close()
- k3.Close()
- k4.Close()
- finally:
- pass
-
- traceguard.__enter__()
-
- try:
- l = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Internet Explorer\\Main', 0, _winreg.KEY_ALL_ACCESS)
- _winreg.SetValueEx(l, 'Search Page', None, _winreg.REG_SZ, 'http://searchbox.digsby.com/')
- l2 = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, 'SOFTWARE\\Microsoft\\Internet Explorer\\Search', 0, _winreg.KEY_ALL_ACCESS)
- _winreg.SetValueEx(l2, 'SearchAssistant', None, _winreg.REG_SZ, 'http://searchbox.digsby.com/ie')
- l.Close()
- l2.Close()
- finally:
- pass
-
-
-
- def is_ffx_running():
- process_list = process_list
- import gui.native.win.process
- return FFX_EXE in process_list()
-
- __all__ = [
- 'start_checking',
- 'set_search_active',
- 'set_homepage_active']
-