# Copyright 2006-2007 Nanorex, Inc. See LICENSE file for details. """ Sponsors.py - sponsors system, exporting PermissionDialog and SponsorableMixin @author: Will @version: $Id$ @copyright: 2006-2007 Nanorex, Inc. See LICENSE file for details. Motivation and design rationale: We want to recoup some of the costs of developing NanoEngineer-1 in a way consistent with its GPL licensing. One way to do that is to have sponsors, and to offer the sponsors advertising space in a way that doesn't bother the user. Some UI dialogs will have buttons with sponsor logos on them, and if you click on a sponsor logo button, you'll get more information and maybe a link to their website. There are no unsolicited pop-ups in this system. We want to be able to update sponsor information without asking the user to download a new version. So we have the program fetch recent sponsor information from our server. We don't want this to annoy the user, in terms of either network bandwidth or privacy concerns, so we have a permission dialog that explains what we're doing and asks the user for permission to do it. Module classification: Contains many levels of code, but exports only a widget and a widget-helper. Still, functionally it may belong in its own toplevel package. [bruce 071217] """ import base64 import md5 import os import random import re import socket import string import threading import types import urllib from xml.dom.minidom import parseString from PyQt4.Qt import QDialog from PyQt4.Qt import QImage from PyQt4.Qt import QPixmap from PyQt4.Qt import QSize from PyQt4.Qt import QIcon from PyQt4.Qt import QGridLayout from PyQt4.Qt import QTextBrowser from PyQt4.Qt import QPushButton from PyQt4.Qt import SIGNAL import foundation.env as env from utilities import debug_flags from platform_dependent.PlatformDependent import find_or_make_Nanorex_subdir from foundation.wiki_help import WikiHelpBrowser from utilities.debug import print_compact_stack, print_compact_traceback from utilities.qt4transition import qt4todo from utilities.prefs_constants import sponsor_download_permission_prefs_key from utilities.prefs_constants import sponsor_permanent_permission_prefs_key from utilities.prefs_constants import sponsor_md5_mismatch_flag_key from utilities.Log import redmsg, orangemsg, greenmsg from utilities.icon_utilities import geticon _sponsordir = find_or_make_Nanorex_subdir('Sponsors') _sponsors = { } # Include a trailing slash in the following sponsor server URLs. _sponsor_servers = \ [#'file:///transfers/', 'http://nanoengineer-1.com/NE1_Sponsors/', 'http://nanohive-1.org/NE1_Sponsors/'] def _fixHtml(rc): #bruce 071217 renamed this to be private startUrl=re.compile('\[') middleUrl=re.compile(' ') finishUrl=re.compile('\]') rc = string.replace(rc, '[P]', '
') rc = string.replace(rc, '[p]', '
') rc = string.replace(rc, '[ul]', '