Exemplo n.º 1
0
 def webView_resource_willSendRequest_redirectResponse_fromDataSource_(
         self, sender, identifier, request, redirectResponse, dataSource):
     '''By reacting to this delegate notification, we can build the page
     the WebView wants to load'''
     msclog.debug_log('webView_resource_willSendRequest_redirectResponse_fromDataSource_')
     url = request.URL()
     msclog.debug_log('Got URL scheme: %s' % url.scheme())
     if url.scheme() == NSURLFileScheme:
         msclog.debug_log(u'Request path is %s' % url.path())
         if self.html_dir in url.path():
             msclog.debug_log(u'request for %s' % url.path())
             filename = unicode(url.lastPathComponent())
             if (filename.endswith(u'.html')
                 and (filename.startswith(u'detail-')
                      or filename.startswith(u'category-')
                      or filename.startswith(u'filter-')
                      or filename.startswith(u'developer-')
                      or filename.startswith(u'updatedetail-')
                      or filename == u'myitems.html'
                      or filename == u'updates.html'
                      or filename == u'categories.html')):
                 try:
                     mschtml.build_page(filename)
                 except BaseException, err:
                     msclog.debug_log(u'Could not build page for %s: %s' % (filename, err))
Exemplo n.º 2
0
 def openMunkiURL(self, url):
     '''Display page associated with munki:// url'''
     parsed_url = urlparse(url)
     if parsed_url.scheme != 'munki':
         msclog.debug_log("URL %s has unsupported scheme" % url)
         return
     filename = mschtml.unquote(parsed_url.netloc)
     # add .html if no extension
     if not os.path.splitext(filename)[1]:
         filename += u'.html'
     if filename.endswith(u'.html'):
         mschtml.build_page(filename)
         self.mainWindowController.load_page(filename)
     else:
         msclog.debug_log("%s doesn't have a valid extension. Prevented from opening" % url)
Exemplo n.º 3
0
 def openMunkiURL(self, url):
     '''Display page associated with munki:// url'''
     parsed_url = urlparse(url)
     if parsed_url.scheme != 'munki':
         msclog.debug_log("URL %s has unsupported scheme" % url)
         return
     filename = mschtml.unquote(parsed_url.netloc)
     # add .html if no extension
     if not os.path.splitext(filename)[1]:
         filename += u'.html'
     if filename.endswith(u'.html'):
         mschtml.build_page(filename)
         self.mainWindowController.load_page(filename)
     else:
         msclog.debug_log("%s doesn't have a valid extension. Prevented from opening" % url)
Exemplo n.º 4
0
 def openURL_withReplyEvent_(self, event, replyEvent):
     '''Handle openURL messages'''
     keyDirectObject = struct.unpack(">i", "----")[0]
     url = event.paramDescriptorForKeyword_(keyDirectObject).stringValue().decode('utf8')
     msclog.log("MSU", "Called by external URL: %s", url)
     parsed_url = urlparse(url)
     if parsed_url.scheme != 'munki':
         msclog.debug_log("URL %s has unsupported scheme" % url)
         return
     filename = mschtml.unquote(parsed_url.netloc)
     # add .html if no extension
     if not os.path.splitext(filename)[1]:
         filename += u'.html'
     if filename.endswith(u'.html'):
         mschtml.build_page(filename)
         self.mainWindowController.load_page(filename)
     else:
         msclog.debug_log("%s doesn't have a valid extension. Prevented from opening" % url)
Exemplo n.º 5
0
 def openURL_withReplyEvent_(self, event, replyEvent):
     '''Handle openURL messages'''
     keyDirectObject = struct.unpack(">i", "----")[0]
     url = event.paramDescriptorForKeyword_(
         keyDirectObject).stringValue().decode('utf8')
     msclog.log("MSU", "Called by external URL: %s", url)
     parsed_url = urlparse(url)
     if parsed_url.scheme != 'munki':
         msclog.debug_log("URL %s has unsupported scheme" % url)
         return
     filename = mschtml.unquote(parsed_url.netloc)
     # add .html if no extension
     if not os.path.splitext(filename)[1]:
         filename += u'.html'
     if filename.endswith(u'.html'):
         mschtml.build_page(filename)
         self.mainWindowController.load_page(filename)
     else:
         msclog.debug_log(
             "%s doesn't have a valid extension. Prevented from opening" %
             url)