@@ -0,0 +1,2562 @@
+# -*- coding: utf-8 -*-%0A%22%22%22%0A    This program is free software; you can redistribute it and/or modify%0A    it under the terms of the GNU General Public License as published by%0A    the Free Software Foundation; either version 3 of the License,%0A    or (at your option) any later version.%0A%0A    This program is distributed in the hope that it will be useful,%0A    but WITHOUT ANY WARRANTY; without even the implied warranty of%0A    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.%0A    See the GNU General Public License for more details.%0A%0A    You should have received a copy of the GNU General Public License%0A    along with this program; if not, see %3Chttp://www.gnu.org/licenses/%3E.%0A%0A    @author: RaNaN, Godofdream, zoidberg%0A%22%22%22%0Aimport sys, httplib%0Afrom module.plugins.Hook import Hook%0A%0Aclass WindowsPhoneToastNotify(Hook):%0A    __name__ = %22WindowsPhoneToastNotify%22%0A    __version__ = %220.01%22%0A    __description__ = %22%22%22Send push notifications to Windows Phone.%22%22%22%0A    __author_name__ = (%22Andy Voigt%22)%0A    __author_mail__ = (%22phone-support@hotmail.de%22)%0A    __config__ = %5B(%22activated%22, %22bool%22, %22Activated%22, False),%0A                  (%22force%22, %22bool%22, %22Force even if client is connected%22, False),%0A                  (%22pushId%22, %22pId%22, %22pushId%22, %22%22),%0A                  (%22pushUrl%22,%22pUrl%22,%22pushUrl%22, %22%22)%5D%0A%0A    def setup(self):%0A        self.info = %7B%7D%0A    %0A    def getXmlData(self):%0A        myxml = %22%3C?xml version='1.0' encoding='utf-8'?%3E %3Cwp:Notification xmlns:wp='WPNotification'%3E %3Cwp:Toast%3E %0A%3Cwp:Text1%3EPyload Mobile%3C/wp:Text1%3E %3Cwp:Text2%3ECaptcha waiting!%3C/wp:Text2%3E %3C/wp:Toast%3E %3C/wp:Notification%3E%22%0A        return myxml%0A%0A    def doRequest(self):%0A        URL = self.getConfig(%22pushUrl%22)%0A        request = self.getXmlData()%0A        webservice = httplib.HTTP(URL)%0A        webservice.putrequest(%22POST%22, self.getConfig(%22pushId%22))%0A        webservice.putheader(%22Host%22, URL)%0A        webservice.putheader(%22Content-type%22, %22text/xml%22)%0A        webservice.putheader(%22X-NotificationClass%22, %222%22)%0A        webservice.putheader(%22X-WindowsPhone-Target%22, %22toast%22)%0A        webservice.putheader(%22Content-length%22, %22%25d%22 %25 len(request))%0A        webservice.endheaders()%0A        webservice.send(request)%0A        #statuscode, statusmessage, header = webservice.getreply()%0A        #result = webservice.getfile().read()%0A        webservice.close()%0A%0A    def newCaptchaTask(self, task):%0A        if not self.getConfig(%22pushId%22) or not self.getConfig(%22pushUrl%22):%0A            return False%0A%0A        if self.core.isClientConnected() and not self.getConfig(%22force%22):%0A            return False%0A%0A        self.doRequest()%0A%0A

create WindowsPhoneToastNotify hook