Esempio n. 1
0
    def handle_cookiesSave_clicked(self):
        cookieJar = self.framework.get_global_cookie_jar()
        cookieList = cookieJar.allCookies()
        domain = str(self.mainWindow.cookiesCookieJarDomainEdit.text())
        name = str(self.mainWindow.cookiesCookieJarNameEdit.text())
        value = str(self.mainWindow.cookiesCookieJarValueEdit.text())
        if not (domain and name and value):
            return
        cookie = self.find_cookie_by_domain_and_name(cookieList, domain, name)
        if cookie is None:
            # new
            cookie = QNetworkCookie(name, value)
            index = -1
        else:
            index = cookieList.index(cookie)

        cookie.setName(name)
        cookie.setDomain(domain)
        cookie.setValue(value)
        cookie.setPath(str(self.mainWindow.cookiesCookieJarPathEdit.text()))
        if self.mainWindow.cookiesCookieJarSessionCookieCheckbox.isChecked():
            cookie.setExpirationDate(QDateTime())
        else:
            cookie.setExpirationDate(self.mainWindow.cookiesCookieJarExpiryEdit.dateTime())
        cookie.setSecure(self.mainWindow.cookiesCookieJarSecureCheckbox.isChecked())
        cookie.setHttpOnly(self.mainWindow.cookiesCookieJarHttpOnlyCheckbox.isChecked())

        if -1 == index:
            cookieList.append(cookie)
        else:
            cookieList[index] = cookie

        cookieJar.setAllCookies(cookieList)
        self.populate_cookie_jar_tree()
Esempio n. 2
0
    def load(self):
      try:
        ds = pickle.load(open(self.m_cookiesFile, 'rb'))
      except:
        ds = []
      qs = []
      t = int(time.time())
      for d in ds:
        if d['expirationDate'] > t and not d['isSessionCookie']:
          c = QNetworkCookie(d['name'],d['value'])
          c.setDomain(d['domain'])
          c.setExpirationDate(QDateTime.fromTime_t(d['expirationDate']))
          c.setHttpOnly(d['isHttpOnly'])
          c.setSecure(d['isSecure'])
          c.setPath(d['path'])
          qs.append(c)

      #for c in cs
      self.setAllCookies(qs)
Esempio n. 3
0
    def har_cookie2qt(cls, cookie):
        qcookie = QNetworkCookie()
        qcookie.setName(cookie["name"])
        qcookie.setValue(cookie["value"])

        if 'domain' in cookie:
            qcookie.setDomain(cookie["domain"])

        if 'httpOnly' in cookie:
            qcookie.setHttpOnly(cookie["httpOnly"])

        if 'secure' in cookie:
            qcookie.setSecure(cookie["secure"])

        if 'path' in cookie:
            qcookie.setPath(cookie["path"])

        if cookie.get('expires'):
            expires = QDateTime.fromString(cookie["expires"], Qt.ISODate)
            qcookie.setExpirationDate(expires)

        return qcookie
Esempio n. 4
0
    def har_cookie2qt(cls, cookie):
        qcookie = QNetworkCookie()
        qcookie.setName(cookie["name"])
        qcookie.setValue(cookie["value"])

        if 'domain' in cookie:
            qcookie.setDomain(cookie["domain"])

        if 'httpOnly' in cookie:
            qcookie.setHttpOnly(cookie["httpOnly"])

        if 'secure' in cookie:
            qcookie.setSecure(cookie["secure"])

        if 'path' in cookie:
            qcookie.setPath(cookie["path"])

        if cookie.get('expires'):
            expires = QDateTime.fromString(cookie["expires"], Qt.ISODate)
            qcookie.setExpirationDate(expires)

        return qcookie
Esempio n. 5
0
    def handle_cookiesSave_clicked(self):
        cookieJar = self.framework.get_global_cookie_jar()
        cookieList = cookieJar.allCookies()
        domain = str(self.mainWindow.cookiesCookieJarDomainEdit.text())
        name = str(self.mainWindow.cookiesCookieJarNameEdit.text())
        value = str(self.mainWindow.cookiesCookieJarValueEdit.text())
        if not (domain and name and value):
            return
        cookie = self.find_cookie_by_domain_and_name(cookieList, domain, name)
        if cookie is None:
            # new
            cookie = QNetworkCookie(name, value)
            index = -1
        else:
            index = cookieList.index(cookie)

        cookie.setName(name)
        cookie.setDomain(domain)
        cookie.setValue(value)
        cookie.setPath(str(self.mainWindow.cookiesCookieJarPathEdit.text()))
        if self.mainWindow.cookiesCookieJarSessionCookieCheckbox.isChecked():
            cookie.setExpirationDate(QDateTime())
        else:
            cookie.setExpirationDate(
                self.mainWindow.cookiesCookieJarExpiryEdit.dateTime())
        cookie.setSecure(
            self.mainWindow.cookiesCookieJarSecureCheckbox.isChecked())
        cookie.setHttpOnly(
            self.mainWindow.cookiesCookieJarHttpOnlyCheckbox.isChecked())

        if -1 == index:
            cookieList.append(cookie)
        else:
            cookieList[index] = cookie

        cookieJar.setAllCookies(cookieList)
        self.populate_cookie_jar_tree()