Example #1
0
// mDNS setup has to be done while joined to network
int8_t GSwifi::setupMDNS() {
    char *cmd;

    // no impact on discoverability
    // command(PB("AT+DHCPSRV",1), GSCOMMANDMODE_NORMAL);

    command(PB("AT+MDNSSTART",1), GSCOMMANDMODE_NORMAL);

    // ex: "00:1d:c9:01:99:99"
    cmd = PB("AT+MDNSHNREG=IRKitXXXX,local",1);
    strcpy( cmd+13, hostname() );
    cmd[22] = ',';
    command(cmd, GSCOMMANDMODE_MDNS);

    cmd = PB("AT+MDNSSRVREG=IRKitXXXX,,_irkit,_tcp,local,80",1);
    strcpy( cmd+14, hostname() );
    cmd[23] = ',';
    command(cmd, GSCOMMANDMODE_MDNS);

    command(PB("AT+MDNSANNOUNCE",1), GSCOMMANDMODE_NORMAL);
    if (did_timeout_) {
        return -1;
    }
    return 0;
}
// Get the full URI of the request_rec's request location 
// clean_params specifies whether or not all openid.* and modauthopenid.* params should be cleared
static void full_uri(request_rec *r, std::string& result, modauthopenid_config *s_cfg, bool clean_params=false) {
  std::string hostname(r->hostname);
  std::string uri(r->uri);
  apr_port_t i_port = ap_get_server_port(r);
  // Fetch the APR function for determining if we are looking at an https URL
  APR_OPTIONAL_FN_TYPE(ssl_is_https) *using_https = APR_RETRIEVE_OPTIONAL_FN(ssl_is_https);
  std::string prefix = (using_https != NULL && using_https(r->connection)) ? "https://" : "http://";
  char *port = apr_psprintf(r->pool, "%lu", (unsigned long) i_port);
  std::string s_port = (i_port == 80 || i_port == 443) ? "" : ":" + std::string(port);

  std::string args;
  if(clean_params) {
    opkele::params_t params;
    if(r->args != NULL) params = modauthopenid::parse_query_string(std::string(r->args));
    modauthopenid::remove_openid_vars(params);
    args = params.append_query("", "");
  } else {
    args = (r->args == NULL) ? "" : "?" + std::string(r->args);
  }

  if(s_cfg->server_name == NULL)
    result = prefix + hostname + s_port + uri + args;
  else
    result = std::string(s_cfg->server_name) + uri + args;
}
Example #3
0
 // handle addressed of the format: "www.news.com:80" or "192.168.0.1:smtp"
 InetAddress::InetAddress(const char* _hostname)
 {
     std::string hostname(_hostname);
     std::string::size_type colonPos = hostname.find(':');
     if (std::string::npos == colonPos)
     {
         // no port specified - use 0
         InetAddress addr (_hostname, 0);
         m_address = addr.m_address;
     }
     else
     {
         std::string portStr = hostname.substr (colonPos + 1);
         hostname = hostname.substr (0, colonPos);
         
         try
         {
             unsigned short portNum = neo::parseUnsignedShort (portStr);
             InetAddress addr (hostname.c_str(), portNum);
             m_address = addr.m_address;
         }
         catch (neo::ParseException)
         {
             // the port is not a number - look it up as a service name 
             InetAddress addr (hostname.c_str(), portStr.c_str(), "tcp");
             m_address = addr.m_address;
         }
     }
 }
Example #4
0
    void download_file(vcpkg::Files::Filesystem& fs,
                       const std::string& url,
                       const fs::path& download_path,
                       const std::string& sha512)
    {
        const std::string download_path_part = download_path.u8string() + ".part";
        std::error_code ec;
        fs.remove(download_path, ec);
        fs.remove(download_path_part, ec);
#if defined(_WIN32)
        auto url_no_proto = url.substr(8); // drop https://
        auto path_begin = Util::find(url_no_proto, '/');
        std::string hostname(url_no_proto.begin(), path_begin);
        std::string path(path_begin, url_no_proto.end());

        winhttp_download_file(fs, download_path_part.c_str(), hostname, path);
#else
        const auto code = System::cmd_execute(
            Strings::format(R"(curl -L '%s' --create-dirs --output '%s')", url, download_path_part));
        Checks::check_exit(VCPKG_LINE_INFO, code == 0, "Could not download %s", url);
#endif

        verify_downloaded_file_hash(fs, url, download_path_part, sha512);
        fs.rename(download_path_part, download_path, ec);
        Checks::check_exit(VCPKG_LINE_INFO,
                           !ec,
                           "Failed to do post-download rename-in-place.\n"
                           "fs.rename(%s, %s, %s)",
                           download_path_part,
                           download_path.u8string(),
                           ec.message());
    }
Example #5
0
QlipperNetwork::QlipperNetwork(QObject *parent)
    : QObject(parent)
{
    setObjectName("qlipperNetwork");

#ifdef ENABLE_NETWORK_CLIPBOARD_SHARING
    QString hostname(QHostInfo::localHostName());
    if (hostname.isEmpty())
        hostname = "unknown";

    QString uname;
#ifdef Q_OS_UNIX
    // Mac, linux, and the other unices.
    uname = qgetenv("USER");
#endif
#ifdef Q_WS_WIN
        // Windows.
    uname = qgetenv("USERNAME");
#endif
    if (uname.isEmpty())
        uname = "unknown";

    m_id = uname + "@" + hostname;

    m_socket = new QUdpSocket(this);
    bool r = m_socket->bind(QlipperPreferences::Instance()->networkPort(), QUdpSocket::ShareAddress);
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(readData()));
    if (!r)
        qDebug() << "socket bound:" << r << m_socket->error() << m_socket->errorString();
#endif
}
Example #6
0
    std::pair<std::string, std::vector<std::string> > getLocalIps()
    {
        std::vector<char> hostname(80);
        int ret = gethostname(&hostname[0], static_cast<int>(hostname.size()));
        int err = Platform::OS::BsdSockets::GetLastError();

        RCF_VERIFY(
            ret != -1, 
            RCF::Exception( _RcfError_Socket("gethostname()"), err, RcfSubsystem_Os))(ret);

        hostent *phe = gethostbyname(&hostname[0]);
        err = Platform::OS::BsdSockets::GetLastError();

        RCF_VERIFY(
            phe, 
            RCF::Exception( _RcfError_Socket("gethostbyname()"), err, RCF::RcfSubsystem_Os));

        std::vector<std::string> ips;
        for (int i = 0; phe->h_addr_list[i] != 0; ++i) {
            struct in_addr addr;
            memcpy(&addr, phe->h_addr_list[i], sizeof( in_addr));
            ips.push_back(inet_ntoa(addr));
        }

        return std::make_pair( std::string(&hostname[0]), ips);
    }
Example #7
0
static struct hostent *gethostbyname(const char *hostname_) {
	std::string hostname(hostname_);

	auto it = hosts.find(hostname);
	if (it != hosts.end()) {
		return &(*it).second;
	}

	struct hostent newHostEnt;

	newHostEnt.h_name = new char[hostname.size()];
	strncpy(newHostEnt.h_name, hostname.c_str(), hostname.size());

	fuzzRead(reinterpret_cast<char *>(&newHostEnt.h_addrtype), sizeof(newHostEnt.h_addrtype));

	newHostEnt.h_addr_list = new char*[2];
	newHostEnt.h_addr_list[0] = newHostEnt.h_name;
	newHostEnt.h_addr_list[1] = NULL;

	// TODO: fuzz these too
	newHostEnt.h_aliases = NULL;
	newHostEnt.h_length = 0;

	auto retval = hosts.emplace(std::move(hostname), newHostEnt);
	assert(retval.second);
	it = retval.first;

	return &(*it).second;
}
Example #8
0
	void resolveDocumentRoot(x0::HttpRequest *in) {
		if (in->document_root.empty())
		{
			x0::BufferRef hostname(in->header("Host"));

			std::size_t n = hostname.find(":");
			if (n != x0::BufferRef::npos)
			{
				hostname = hostname.ref(0, n);
			}

			std::string dr;
			dr.reserve(server_root_.size() + std::max(hostname.size(), default_host_.size()) + document_root_.size());
			dr += server_root_;
			dr += hostname.str();
			dr += document_root_;

			x0::FileInfoPtr fi = in->connection.server().fileinfo(dr);
			if (!fi || !fi->is_directory())
			{
				dr.clear();
				dr += server_root_;
				dr += default_host_;
				dr += document_root_;

				fi = in->connection.server().fileinfo(dr);
				if (!fi || !fi->is_directory())
				{
					return;
				}
			}

			in->document_root = dr;
		}
	}
Example #9
0
Pegasus::Boolean CIMClient::verifyCertificate(Pegasus::SSLCertificateInfo &ci, void *data)
{
    if (!ci.getResponseCode()) {
        // Pre-verify of the certificate failed, immediate return
        return false;
    }

    CIMClient *fake_this = reinterpret_cast<CIMClient*>(data);
    Pegasus::String hostname(fake_this->m_url_info.hostname());

    // Verify against DNS names
    Pegasus::Array<Pegasus::String> dnsNames = ci.getSubjectAltNames().getDnsNames();
    for (Pegasus::Uint32 i = 0; i < dnsNames.size(); ++i) {
        if (matchPattern(dnsNames[i], hostname))
            return true;
    }

    // Verify against IP addresses
    Pegasus::Array<Pegasus::String> ipAddresses = ci.getSubjectAltNames().getIpAddresses();
    for (Pegasus::Uint32 i = 0; i < ipAddresses.size(); ++i) {
        if (matchPattern(ipAddresses[i], hostname))
            return true;
    }

    // Verify against Common Name
    return matchPattern(ci.getSubjectCommonName(), hostname);
}
Tomahawk::ScriptJob*
Tomahawk::Utils::TomaHkLinkGeneratorPlugin::openLink( const Tomahawk::album_ptr& album ) const
{
    QVariantMap data;
    data[ "url" ] = QUrl::fromUserInput( QString( "%1/album/%2/%3" ).arg( hostname() ).arg( album->artist().isNull() ? QString() : album->artist()->name() ).arg( album->name() ) );;
    return new SyncScriptJob( data );
}
Tomahawk::ScriptJob*
Tomahawk::Utils::TomaHkLinkGeneratorPlugin::openLink( const Tomahawk::artist_ptr& artist ) const
{
    QVariantMap data;
    data[ "url" ] = QString( "%1/artist/%2" ).arg( hostname() ).arg( artist->name() );
    return new SyncScriptJob( data );
}
Example #12
0
int configurationPage::configSystem()
{
	// set root password ...
	if(rootPasswordLineEdit->text() > 0)
	{
		setStatus(tr("Setting root password"), INFORMATION);
        mountRoot.start("openssl passwd -1 " + rootPasswordLineEdit->text());
        mountRoot.waitForFinished();
        croot.exec("usermod -p "+ mountRoot.readAllStandardOutput() + " root");
	}

    if(hostnameLineEdit->text() > 0)
    {
        setStatus(tr("Setting Hostnam"), INFORMATION);
        //croot.exec("hostnamectl set-hostname " + hostnameLineEdit->text());
        ///mountRoot.start("echo " + hostnameLineEdit->text() + " > " + rootPath+"/etc/hostname");
        ///mountRoot.waitForFinished();
        QFile hostnamefile(rootPath+"/etc/hostname");
        hostnamefile.open(QIODevice::WriteOnly);
        QTextStream hostname(&hostnamefile);
        hostname << hostnameLineEdit->text();
        hostnamefile.close();
    }

    croot.unprepare();


	return 0;
}
void simplesocket::resolve (struct addrinfo * hint) {
  int err;
  int on = 1;
  
  char portStr[255];
  snprintf (portStr, sizeof(portStr), "%d", _port);
  
  if ((err = getaddrinfo (hostname(), portStr, hint, &_addresses)) != 0) {
    if (_debug)
      cerr << "Error in name resolution for " << name()
	   << ", with error " << gai_strerror(err) << "\n";
    _nameResolved = false;
    return;
  }
  
  _nameResolved = true;
  _socketfd = socket (AF_INET, SOCK_STREAM, 0);
  if (_socketfd < 0) {
    if (_debug)
      cerr << "SOCKET CREATION FAILURE... aborting.\n";
    return;
  }
  
  setsockopt (_socketfd, 
	      SOL_SOCKET,
	      SO_REUSEADDR, 
	      (void *) &on,
	      sizeof (on));
}
Example #14
0
// --------------------------------------------------------------------------
int main(int argc, char** argv)
{
    struct params* params = 0;
    int sockfd = -1;

    params = alloc_params();
    extract_params_from_cmdline_options(params, argc, argv);

    if (is_help_desired(params)) {
        show_help(argv[0]);
        goto out;
    }

    sockfd = inet_connect(hostname(params), portnumber(params), SOCK_STREAM);
    if (sockfd < 0) {
        fprintf(stderr, "failed to connect to remote host.\n");
        goto out;
    }

    do_interactive_loop(sockfd);

out:
    if (sockfd > 0) {
        close(sockfd);
    }

    free_params(params);

    return 0;
}
Example #15
0
int
main(int argc, char **argv)
{
    struct DiskPartition *dp;
    Inode testcreate;
    Device devno;
    int fd, count;
    char *buff="This is a test string";
    Partent pe, pf;
    FILE *vtab;
    int rc;
    char host[256];

    /* write a vicetab file */
    hostname(host);

    /* set up a simple partition & ftree partition */
    /* they must be on different diskpartions */
    pe = Partent_create(host, "simpled", "simple","");
    pf = Partent_create(host, "/tmp/f", "ftree","width=8,depth=5");
    unlink("vicetab");
    rc = creat("vicetab", 00600);
    CODA_ASSERT( rc != -1 );
    vtab = Partent_set("vicetab", "r+");
    rc = Partent_add(vtab, pe);
    CODA_ASSERT( rc == 0 );
    rc = Partent_add(vtab, pf);
    CODA_ASSERT( rc == 0 );
    Partent_free(&pe);
    Partent_free(&pf);
    Partent_end(vtab);
    printf("Make sure to run makeftree vicetab /tmp/f before continuing!\n");
    return 0;
    
}
Example #16
0
int main(int argc, char **argv)
{
	/* init */
	ServiceInstaller serviceInstaller;
	serviceInstaller.supportComponentType(Component::CLI, new CliInstallersFactory());
	serviceInstaller.supportComponentType(Component::DEAMON, new DaemonInstallersFactory());

	std::vector<Component *> components;
	components.push_back(new CLI(LINUX));
	components.push_back(new Daemon());
	Service service(components);

	std::string hostname("hostname");
	UserPreferences prefs = UserPreferences::newPreferences(hostname, LINUX);

	/* install */
	serviceInstaller.installService(service, prefs);

	/* destroy */
	serviceInstaller.deleteSupported();

	std::vector<Component *>::iterator itr;
	for (itr = components.begin(); itr != components.end(); itr++) {
		delete (*itr);
	}
	return 0;
}
void StaticDomainNameResolver::addXMPPClientService(const std::string& domain, const HostAddressPort& address) {
	static int hostid = 0;
	std::string hostname(std::string("host-") + boost::lexical_cast<std::string>(hostid));
	hostid++;

	addService("_xmpp-client._tcp." + domain, ServiceQuery::Result(hostname, address.getPort(), 0, 0));
	addAddress(hostname, address.getAddress());
}
Example #18
0
Endpoint::Endpoint(Dispatcher &d) :
    dispatcher(d),
    session(NULL),
    protocol(NULL),
    sock(d.io_service())
{
    local.hostname = hostname();
}
Example #19
0
void NetworkDialog::savePreferences()
{
    Settings::setNickname(nickname());
    if (m_hostname) {
        Settings::setHostname(hostname());
    }
    Settings::setPort(port());
    Settings::self()->save();
}
Handle<Value>
dnsServiceGetAddrInfo(Arguments const& args) {
    HandleScope scope;

    if (argumentCountMismatch(args, 7)) {
        return throwArgumentCountMismatchException(args, 7);
    }

    if ( ! ServiceRef::HasInstance(args[0])) {
        return throwTypeError("argument 1 must be a DNSServiceRef (sdRef)");
    }
    ServiceRef * serviceRef = ObjectWrap::Unwrap<ServiceRef>(args[0]->ToObject());
    if (serviceRef->IsInitialized()) {
        return throwError("DNSServiceRef is already initialized");
    }

    if ( ! args[1]->IsInt32()) {
        return throwError("argument 2 must be an integer (DNSServiceFlags)");
    }
    DNSServiceFlags flags = args[1]->ToInteger()->Int32Value();

    if ( ! args[2]->IsInt32()) {
        return throwTypeError("argument 3 must be an integer (interfaceIndex)");
    }
    uint32_t interfaceIndex = args[2]->ToInteger()->Int32Value();

    if ( ! args[3]->IsInt32()) {
        return throwTypeError("argument 4 must be an integer (DNSServiceProtocol)");
    }
    uint32_t protocol = args[3]->ToInteger()->Int32Value();

    if ( ! args[4]->IsString()) {
        return throwTypeError("argument 5 must be a string (hostname)");
    }
    String::Utf8Value hostname(args[4]->ToString());

    if ( ! args[5]->IsFunction()) {
        return throwTypeError("argument 6 must be a function (callBack)");
    }
    serviceRef->SetCallback(Local<Function>::Cast(args[5]));

    if ( ! args[6]->IsNull() && ! args[6]->IsUndefined()) {
        serviceRef->SetContext(args[6]);
    }

    DNSServiceErrorType error = DNSServiceGetAddrInfo( & serviceRef->GetServiceRef(),
            flags, interfaceIndex, protocol, *hostname, OnAddressInfo, serviceRef);

    if (error != kDNSServiceErr_NoError) {
        return throwMdnsError("dnsServiceGetAddrInfo()", error);
    }
    if ( ! serviceRef->SetSocketFlags()) {
        return throwError("Failed to set socket flags (O_NONBLOCK, FD_CLOEXEC)");
    }

    return Undefined();
}
Example #21
0
string g_NetService_gethostname(const string& ip_or_hostname)
{
    string hostname(CSocketAPI::gethostbyaddr(
        g_NetService_gethostbyname(ip_or_hostname), eOn));
    if (hostname.empty()) {
        NCBI_THROW_FMT(CNetServiceException, eCommunicationError,
            "g_NetService_gethostname('" << ip_or_hostname << "') failed");
    }
    return hostname;
}
Example #22
0
int zmq::resolve_ip_hostname (sockaddr_storage *addr_, socklen_t *addr_len_,
    const char *hostname_)
{
    //  Find the ':' that separates hostname name from service.
    const char *delimiter = strrchr (hostname_, ':');
    if (!delimiter) {
        errno = EINVAL;
        return -1;
    }

    //  Separate the hostname and service.
    std::string hostname (hostname_, delimiter - hostname_);
    std::string service (delimiter + 1);

    //  Set up the query.
    addrinfo req;
    memset (&req, 0, sizeof (req));

    //  We only support IPv4 addresses for now.
    req.ai_family = AF_INET;

    //  Need to choose one to avoid duplicate results from getaddrinfo() - this
    //  doesn't really matter, since it's not included in the addr-output.
    req.ai_socktype = SOCK_STREAM;
    
    //  Avoid named services due to unclear socktype.
    req.ai_flags = AI_NUMERICSERV;

    //  Resolve host name. Some of the error info is lost in case of error,
    //  however, there's no way to report EAI errors via errno.
    addrinfo *res;
    int rc = getaddrinfo (hostname.c_str (), service.c_str (), &req, &res);
    if (rc) {

        switch (rc) {
        case EAI_MEMORY:
            errno = ENOMEM;
            break;
        default:
        errno = EINVAL;
            break;
        }

        return -1;
    }

    //  Copy first result to output addr with hostname and service.
    zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_));
    memcpy (addr_, res->ai_addr, res->ai_addrlen);
    *addr_len_ = (socklen_t) res->ai_addrlen;
 
    freeaddrinfo (res);
    
    return 0;
}
Example #23
0
static unsigned posted (unsigned margin)

{
	time_t now = time (& now);
	static char datetime [LOGTIME_LEN];
	strftime (datetime, sizeof (datetime), LOGTIME, localtime (& now));
	indent (margin++, "<div class='%s'>", style_posted);
	indent (margin, "Posted %s on %s by %s", datetime, hostname (), username (getuid ()));
	indent (margin--, "</div>");
	return (margin);
}
Example #24
0
string _sh_command(string command, bool force_local, 
		   bool force_display_settings)
{
    // Fetch display settings
    string display;
    if (command_shell != 0)
	display = XDisplayString(XtDisplay(command_shell));
    else if (getenv("DISPLAY") != 0)
	display = getenv("DISPLAY");
    else
	display = "";

    // Make sure display contains host name
    if (display.contains("unix:", 0) || display.contains(":", 0))
    {
	display = string(hostname()) + display.from(":");
    }

    // Make sure display contains fully qualified host name
    if (display.contains(":") && !display.contains("::"))
    {
	string host = display.before(':');
	display = string(fullhostname(host.chars())) + display.from(":");
    }

    string settings = "";
    if (!display.empty())
    {
	settings += 
	    "DISPLAY=${DISPLAY-" + sh_quote(display) + "}; export DISPLAY; ";
    }
    settings += set_environment_command();

    if (force_local || !remote_gdb())
    {
	if (command.empty())
	    return "";
	if (force_display_settings)
	    command = settings + command;
	return "/bin/sh -c " + sh_quote(command);
    }

    string rsh = app_data.rsh_command;
    const string login = app_data.debugger_host_login;
    if (!login.empty())
	rsh += " -l " + login;

    rsh += " " + gdb_host;

    if (!command.empty())
	rsh += " /bin/sh -c " + sh_quote(sh_quote(settings + command));

    return rsh;
}
Example #25
0
std::string CSysInfo::GetDeviceName()
{
  std::string friendlyName = CSettings::GetInstance().GetString(CSettings::SETTING_SERVICES_DEVICENAME);
  if (StringUtils::EqualsNoCase(friendlyName, CCompileInfo::GetAppName()))
  {
    std::string hostname("[unknown]");
    g_application.getNetwork().GetHostName(hostname);
    return StringUtils::Format("%s (%s)", friendlyName.c_str(), hostname.c_str());
  }
  
  return friendlyName;
}
Example #26
0
string g_NetService_TryResolveHost(const string& ip_or_hostname)
{
    unsigned ip = CSocketAPI::gethostbyname(ip_or_hostname, eOn);
    if (ip == 0)
        return ip_or_hostname;

    string hostname(CSocketAPI::gethostbyaddr(ip, eOn));
    if (hostname.empty())
        return ip_or_hostname;

    return hostname;
}
Example #27
0
void ControlWidget::initConnect()
{
   if( !mConnected )
   {
      QString hostname( "localhost" );
      int port = Settings::value( Settings::PartymanDerMixDport );

      if( Settings::value( Settings::PartymanDerMixDrun ) )
      {
         QStringList args;
         QString params( Settings::value( Settings::PartymanDerMixDparams ) );
         args << "-c" << QString("main.port=%1").arg( port );
         if( !params.isEmpty() )
         {
            args << params.split(' ');
         }
         qlonglong pid = Settings::value( Settings::PartymanDerMixDpid );
         if( pid > 0 )
         {
#ifdef Q_OS_UNIX
            ::kill( static_cast<pid_t>( pid ), SIGTERM );
#endif
         }
         mpDerMixDprocess->start( Settings::value( Settings::PartymanDerMixDcmd ), args );
         /* block until dermixd is up an running */
         for( mWaitForDerMixD = true; mWaitForDerMixD; )
         {
            QCoreApplication::processEvents();
         }
         if( !mDerMixDstarted )
         {
            QMessageBox::critical( this, QApplication::applicationName(),
                                   tr("Could not start DerMixD") );
         }
         pid = static_cast<qlonglong>( mpDerMixDprocess->pid() );
         Settings::setValue( Settings::PartymanDerMixDpid, pid );
      }
      else
      {
         mDerMixDstarted = true;
         hostname = Settings::value( Settings::PartymanDerMixDhost );
      }
      mConnected = true;
      mpPlayer[0]->connectTo( hostname, port );
      mpPlayer[1]->connectTo( hostname, port );
      mpStartButton->setMenu( mpStartButtonMenu );
      mpTrayIcon->setContextMenu( mpTrayIconPlayMenu );
      mpPlayAction->setChecked( true );
      mpSkipAction->setDisabled( mKioskMode );
      emit signalConnected( true );
   }
   handlePause( true );
}
Example #28
0
void UpgradeChecker::fetch()
{
	QString filename("scribusversions.xml");
	m_tempFile=ScPaths::getTempFileDir()+filename;

	m_fin=false;

	m_file=new QFile(m_tempFile);
	m_networkManager=new QNetworkAccessManager(this);
	if (m_networkManager!=0 && m_file!=0)
	{
		outputText( tr("No data on your computer will be sent to an external location"));
		qApp->processEvents();
		if(m_file->open(QIODevice::ReadWrite))
		{
			QString hostname("services.scribus.net");
			QString filepath("/"+filename);
			QUrl fileURL(QString("http://%1%2").arg(hostname).arg(filepath));
			outputText("<b>"+ tr("Attempting to get the Scribus version update file:")+"</b>");
			outputText(fileURL.toString());

			QNetworkRequest networkRequest(fileURL);
			m_networkReply = m_networkManager->get(networkRequest);
			connect(m_networkReply, SIGNAL(finished()), SLOT(downloadFinished()));
			connect(m_networkReply, SIGNAL(readyRead()), SLOT(downloadReadyRead()));

			int waitCount=0;
			while (!m_fin && waitCount<20)
			{
					sleep(1);
					++waitCount;
					if (m_writeToConsole)
							std::cout << ". " << std::flush;
					outputText( ".", true );
					qApp->processEvents();
			}
			if (m_writeToConsole)
					std::cout << std::endl;
			if (waitCount>=20)
			{
					outputText("<b>"+ tr("Timed out when attempting to get update file.")+"</b>");
			}
			m_file->close();
		}
		m_file->remove();
	}
	delete m_file;
	m_file=0;
	outputText( tr("Finished") );
	m_networkReply->deleteLater();
	m_networkManager->deleteLater();
}
Example #29
0
//returns >0 or CONNERR.
static int createSocketConnection(const char* parturl, Connection*& conn, bool ssl) {
	const char* port_m1 = strchr(parturl, ':');
	if(!port_m1) {
		return CONNERR_URL;
	}
	std::string hostname(parturl, size_t(port_m1 - parturl));
	int port = atoi(port_m1 + 1);
	if(port <= 0 || port >= 1 << 16) {
		return CONNERR_URL;
	}
	conn = newSocketConnection(hostname, port, ssl);
	return 1;
}
int UIWizardExportAppPageBasic3::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = UIWizardPage::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 1)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 1;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = format(); break;
        case 1: *reinterpret_cast< bool*>(_v) = isManifestSelected(); break;
        case 2: *reinterpret_cast< QString*>(_v) = username(); break;
        case 3: *reinterpret_cast< QString*>(_v) = password(); break;
        case 4: *reinterpret_cast< QString*>(_v) = hostname(); break;
        case 5: *reinterpret_cast< QString*>(_v) = bucket(); break;
        case 6: *reinterpret_cast< QString*>(_v) = path(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setFormat(*reinterpret_cast< QString*>(_v)); break;
        case 1: setManifestSelected(*reinterpret_cast< bool*>(_v)); break;
        case 2: setUserName(*reinterpret_cast< QString*>(_v)); break;
        case 3: setPassword(*reinterpret_cast< QString*>(_v)); break;
        case 4: setHostname(*reinterpret_cast< QString*>(_v)); break;
        case 5: setBucket(*reinterpret_cast< QString*>(_v)); break;
        case 6: setPath(*reinterpret_cast< QString*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}