<commit_before>/*
 * This file is part of accounts-ui
 *
 * Copyright (C) 2009-2010 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

#include "generic-account-setup-context.h"

//project library
#include <AccountsUI/accountsmanagersingleton.h>
#include <AccountsUI/network-session-manager.h>
#include <AccountsUI/common.h>
#include <AccountsUI/validation-data.h>
#include "genericaccountsetupform.h"

//signon
#include <SignOn/Identity>
#include <SignOn/identityinfo.h>
#include <SignOn/SessionData>
#include <SignOn/Error>

//Qt
#include <QDebug>
#include <QTimer>

//accounts-qt lib
#include <Accounts/Account>

//Meegotouch
#include <MInfoBanner>

using namespace Accounts;
using namespace SignOn;

static QStringList parseRealms(QDomElement realmsElement)
{
    QStringList realms;

    if (!realmsElement.isNull()) {
        QDomElement realmElement = realmElement.firstChildElement("realm");
        while (!realmElement.isNull()) {
            QString realm = realmElement.text();

            if (!realm.isEmpty())
                realms.append(realm);
            realmElement = realmElement.nextSiblingElement("realm");
        }
    }

    return realms;
}

/* !! TODO - organize the XML parsing code - should not be spread through
             all the methods that need data from the XML conf file !!
*/
namespace AccountsUI {

class GenericAccountSetupContextPrivate
{
public:
    GenericAccountSetupContextPrivate(GenericAccountSetupContext *parent)
        : genericAccountSetupForm(0)
        , identity(0)
        , authSession(0)
        , networkManager(0)
        , contextIsValidated(false)
        , identityCreated(false)
        , credentialsStored(false)
        , authSessionStopped(false)
        , validationData(QString(), QString(), QVariantMap())
        , q_ptr(parent)
    {}

    ~GenericAccountSetupContextPrivate()
    {
        if (identity)
            identity->deleteLater();

        if (networkManager) {
            networkManager->stopSession();
            networkManager->deleteLater();
        }
    }

    bool storeAccountPassword(const QDomDocument &domDocument);<commit_msg>Bugfix #215884 - Facebook plugin crash is encountered sometimes while trying to configure facebook account<commit_after>/*
 * This file is part of accounts-ui
 *
 * Copyright (C) 2009-2010 Nokia Corporation.
 *
 * Contact: <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

#include "generic-account-setup-context.h"

//project library
#include <AccountsUI/accountsmanagersingleton.h>
#include <AccountsUI/network-session-manager.h>
#include <AccountsUI/common.h>
#include <AccountsUI/validation-data.h>
#include "genericaccountsetupform.h"

//signon
#include <SignOn/Identity>
#include <SignOn/identityinfo.h>
#include <SignOn/SessionData>
#include <SignOn/Error>

//Qt
#include <QDebug>
#include <QTimer>

//accounts-qt lib
#include <Accounts/Account>

//Meegotouch
#include <MInfoBanner>

using namespace Accounts;
using namespace SignOn;

static QStringList parseRealms(QDomElement realmsElement)
{
    QStringList realms;

    if (!realmsElement.isNull()) {
        QDomElement realmElement = realmElement.firstChildElement("realm");
        while (!realmElement.isNull()) {
            QString realm = realmElement.text();

            if (!realm.isEmpty())
                realms.append(realm);
            realmElement = realmElement.nextSiblingElement("realm");
        }
    }

    return realms;
}

/* !! TODO - organize the XML parsing code - should not be spread through
             all the methods that need data from the XML conf file !!
*/
namespace AccountsUI {

class GenericAccountSetupContextPrivate
{
public:
    GenericAccountSetupContextPrivate(GenericAccountSetupContext *parent)
        : genericAccountSetupForm(0)
        , identity(0)
        , authSession(0)
        , networkManager(0)
        , contextIsValidated(false)
        , identityCreated(false)
        , credentialsStored(false)
        , authSessionStopped(false)
        , validationData(QString(), QString(), QVariantMap())
        , q_ptr(parent)
    {}

    ~GenericAccountSetupContextPrivate()
    {
        if (identity)
            identity->deleteLater();

        if (networkManager) {
            networkManager->disconnect();
            networkManager->stopSession();
            networkManager->deleteLater();
        }
    }

    bool storeAccountPassword(const QDomDocument &domDocument);
{'fraction_non_alphanumeric': 0.09479909549486867, 'fraction_numerical': 0.009740824491215863, 'mean_word_length': 3.310344827586207, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3624448', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1553, 'n_words': 487}