Beispiel #1
0
CFErrorRef ResourceError::cfError() const
{
    if (m_isNull) {
        ASSERT(!m_platformError);
        return 0;
    }

    if (!m_platformError) {
        RetainPtr<CFMutableDictionaryRef> userInfo(AdoptCF, CFDictionaryCreateMutable(0, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));

        if (!m_localizedDescription.isEmpty()) {
            RetainPtr<CFStringRef> localizedDescriptionString(AdoptCF, m_localizedDescription.createCFString());
            CFDictionarySetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey, localizedDescriptionString.get());
        }

        if (!m_failingURL.isEmpty()) {
            RetainPtr<CFStringRef> failingURLString(AdoptCF, m_failingURL.createCFString());
            CFDictionarySetValue(userInfo.get(), failingURLStringKey, failingURLString.get());
            RetainPtr<CFURLRef> url(AdoptCF, KURL(ParsedURLString, m_failingURL).createCFURL());
            CFDictionarySetValue(userInfo.get(), failingURLKey, url.get());
        }

#if PLATFORM(WIN)
        if (m_certificate)
            wkSetSSLPeerCertificateData(userInfo.get(), m_certificate.get());
#endif
        
        RetainPtr<CFStringRef> domainString(AdoptCF, m_domain.createCFString());
        m_platformError.adoptCF(CFErrorCreate(0, domainString.get(), m_errorCode, userInfo.get()));
    }

    return m_platformError.get();
}
QNetworkReply::NetworkError OwnCloudNetworkFactory::triggerFeedUpdate(int feed_id) {
  if (userId().isEmpty()) {
    // We need to get user ID first.
    OwnCloudUserResponse info = userInfo();

    if (lastError() != QNetworkReply::NoError) {
      return lastError();
    }
    else {
      // We have new user ID, set it up.
      setUserId(info.userId());
    }
  }

  // Now, we can trigger the update.
  QByteArray raw_output;
  NetworkResult network_reply = NetworkFactory::performNetworkOperation(m_urlFeedsUpdate.arg(userId(),
                                                                                             QString::number(feed_id)),
                                                                        qApp->settings()->value(GROUP(Feeds),
                                                                                                SETTING(Feeds::UpdateTimeout)).toInt(),
                                                                        QByteArray(), QString(), raw_output,
                                                                        QNetworkAccessManager::GetOperation,
                                                                        true, m_authUsername, m_authPassword,
                                                                        true);

  if (network_reply.first != QNetworkReply::NoError) {
    qWarning("ownCloud: Feeds update failed with error %d.", network_reply.first);
  }

  return (m_lastError = network_reply.first);
}
Beispiel #3
0
void ICBMSNACHandler::ProcessIncomingMessageBasic(const SNAC&)
{
	UserInfo userInfo(_input, _inputStream);

	String message;
	bool autoresponse = false;

	TLVReader reader(_input, _inputStream);
	while(reader.Read())
	{
		switch(reader.Type)
		{
		case TLVs::Autoresponse:
			autoresponse = true;
			break;

		case TLVs::MessageData:
			{
				uint16 len = reader.Length;

				// Hey, this part is actually useful, what were the developers thinking?
				uint16 charSet = 0;
				_input >> charSet;
				len -= sizeof(charSet);
				
				// Almost always 0xffff.
				uint16 charSubset = 0;
				_input >> charSubset;
				len -= sizeof(charSubset);

				String messagePart;
				switch(charSet)
				{
				case 0x00:
					messagePart = _input.ReadString<Encoding::ASCII>(len);
					break;

				case 0x02:
					messagePart = _input.ReadString<Encoding::UTF16BE>(len);
					break;

				case 0x03:
					messagePart = _input.ReadString<Encoding::ISO88591>(len);
					break;
				}

				message += messagePart;
			}
			break;
		}
	}

	if(OnMessageReceive != 0)
		OnMessageReceive(userInfo.ScreenName, message.c_str(), autoresponse);
}
Beispiel #4
0
void ICBMSNACHandler::ProcessMissedMessage(const SNAC&)
{
	uint16 channel = 0;
	_input >> channel;

	UserInfo userInfo(_input, _inputStream);
	
	uint16 numMessagesMissed = 0;
	_input >> numMessagesMissed;

	uint16 reason = 0;
	_input >> reason;
}
Beispiel #5
0
std::string URL::authority() const
{
    std::string res;    
    if (hasUserInfo()) {
        res.append(userInfo());
        res.append("@");
    }
    res.append(host());
    if (hasPort()) {
        res.append(":");
        res.append(util::itostr<std::uint16_t>(port()));
    }
    return res;
}
Beispiel #6
0
void ResourceError::platformLazyInit()
{
    if (m_dataIsUpToDate)
        return;

    if (!m_platformError)
        return;

    CFStringRef domain = CFErrorGetDomain(m_platformError.get());
    if (domain == kCFErrorDomainMach || domain == kCFErrorDomainCocoa)
        m_domain ="NSCustomErrorDomain";
    else if (domain == kCFErrorDomainCFNetwork)
        m_domain = "CFURLErrorDomain";
    else if (domain == kCFErrorDomainPOSIX)
        m_domain = "NSPOSIXErrorDomain";
    else if (domain == kCFErrorDomainOSStatus)
        m_domain = "NSOSStatusErrorDomain";
    else if (domain == kCFErrorDomainWinSock)
        m_domain = "kCFErrorDomainWinSock";
    else
        m_domain = domain;

    m_errorCode = CFErrorGetCode(m_platformError.get());

    RetainPtr<CFDictionaryRef> userInfo(AdoptCF, CFErrorCopyUserInfo(m_platformError.get()));
    if (userInfo.get()) {
        CFStringRef failingURLString = (CFStringRef) CFDictionaryGetValue(userInfo.get(), failingURLStringKey);
        if (failingURLString)
            m_failingURL = String(failingURLString);
        else {
            CFURLRef failingURL = (CFURLRef) CFDictionaryGetValue(userInfo.get(), failingURLKey);
            if (failingURL) {
                RetainPtr<CFURLRef> absoluteURLRef(AdoptCF, CFURLCopyAbsoluteURL(failingURL));
                if (absoluteURLRef.get()) {
                    failingURLString = CFURLGetString(absoluteURLRef.get());
                    m_failingURL = String(failingURLString);
                }
            }
        }
        m_localizedDescription = (CFStringRef) CFDictionaryGetValue(userInfo.get(), kCFErrorLocalizedDescriptionKey);
        
#if PLATFORM(WIN)
        m_certificate = wkGetSSLPeerCertificateData(userInfo.get());
#endif
    }

    m_dataIsUpToDate = true;
}
Beispiel #7
0
UserInfo Communicator::login()
{
    QVariantList params = authParams();
    if (params.size() == 0)
        return UserInfo();

    QMap<QString, QVariant> param = params.takeAt(0).toMap();
    param["getpickwurls"] = "1";
    param["getpickws"] = "1";
    param["getmoods"] = "1";
    params.push_back(param);

    // Send request to login.
    request("LJ.XMLRPC.login", params);

    std::auto_ptr<QBuffer> buffer(m_responses.take(m_currentRequestId));
    QByteArray buf = buffer->buffer();

    UserInfo userInfo(buf);
    return userInfo;
}
Beispiel #8
0
void IslInterface::sessionEvent_ServerCompleteList(const Event_ServerCompleteList &event)
{
	for (int i = 0; i < event.user_list_size(); ++i) {
		ServerInfo_User temp(event.user_list(i));
		temp.set_server_id(serverId);
		emit externalUserJoined(temp);
	}
	for (int i = 0; i < event.room_list_size(); ++i) {
		const ServerInfo_Room &room = event.room_list(i);
		for (int j = 0; j < room.user_list_size(); ++j) {
			ServerInfo_User userInfo(room.user_list(j));
			userInfo.set_server_id(serverId);
			emit externalRoomUserJoined(room.room_id(), userInfo);
		}
		for (int j = 0; j < room.game_list_size(); ++j) {
			ServerInfo_Game gameInfo(room.game_list(j));
			gameInfo.set_server_id(serverId);
			emit externalRoomGameListChanged(room.room_id(), gameInfo);
		}
	}
}
	void UserSessionService::OnPost(REXDR::Listener::Link::Handle link, const REXDR::MessageInfo& info, const REXDR::Request& req, void* context)
	{
		// Obtain Logger reference from context
		REXDRServer::REXDRListenerHandler* listener = (REXDRServer::REXDRListenerHandler*)context;
		Common::Log4XWrapper* logger = listener->GetLogger();

		UpdateUserSessionStatus update;
		if ( !update.Load(req) )
		{
			if ( logger->IsErrorEnabled() )
			{
				logger->LogFormat(LL_ERROR, "ProcessUpdate Load() FAILED. Error(%d). Request = %s", XPlatform::GetLastError(), req.toString());
			}
			return;
		}

		// Update Session Storage
		UserSessionInfoPtr userInfo(new UserSessionInfoType(update.userid, update.sessionid, (UserSessionStatus)update.sessionstatus, update.gameid, update.channelid));
		UserSessionStorage::Instance().SetSessionInfo(userInfo);

		if ( logger->IsDebugEnabled() )
		{
			logger->LogFormat(LL_DEBUG, "User(%s) Session(%d) UPDATED\n", update.userid.c_str(), update.sessionid);
		}

		// Prepare for Update Response
		UpdateUserSessionStatusResponse response;
		response.userid = update.userid;
		response.sessionid = update.sessionid;
		response.errorcode = 0;
		response.status.code = REXDR::STATUS_OK;
		response.status.message = "Update success";

		REXDR::Listener::Link::Send(link, info, &response);

		if ( logger->IsDebugEnabled() )
		{
			logger->LogFormat(LL_DEBUG, "User(%s) Session(%d) response sent.\n", response.userid.c_str(), response.sessionid);
		}
	}
Beispiel #10
0
void IslInterface::roomEvent_UserJoined(int roomId, const Event_JoinRoom &event)
{
	ServerInfo_User userInfo(event.user_info());
	userInfo.set_server_id(serverId);
	emit externalRoomUserJoined(roomId, userInfo);
}
Beispiel #11
0
void IslInterface::sessionEvent_UserJoined(const Event_UserJoined &event)
{
	ServerInfo_User userInfo(event.user_info());
	userInfo.set_server_id(serverId);
	emit externalUserJoined(userInfo);
}
Beispiel #12
0
int main()
{
   TTimeStamp timestamp;
   timestamp.Set();
   Int_t revisionNumber = 0;

   //
   // Reading XML
   //

   ROMEString xmlFileName = "$(ROMESYS)/.revision.xml";
   gSystem->ExpandPathName(xmlFileName);
   auto_ptr<ROMEXML> xmlIn(new ROMEXML());

   if(xmlIn->OpenFileForPath(xmlFileName.Data())) {
      ROMEString revisionString;
      ROMEString path;

      path = "Entry";
      Int_t nEntry = xmlIn->NumberOfOccurrenceOfPath(path.Data());

      Int_t iEntry;
      vector<ROMEString> user(nEntry + 1);
      vector<ROMEString> host(nEntry + 1);
      vector<ROMEString> directory(nEntry + 1);
      vector<ROMEString> lastcompile(nEntry + 1);
      Bool_t foundIdenticalEntry = kFALSE;

      auto_ptr<UserGroup_t> userInfo(gSystem->GetUserInfo());
      user[nEntry]        = userInfo->fUser;
      host[nEntry]        = gSystem->HostName();
      directory[nEntry]   = "$(ROMESYS)";
      gSystem->ExpandPathName(directory[nEntry]);
      lastcompile[nEntry] = timestamp.AsString();

      path.SetFormatted("Revision");
      xmlIn->GetPathValue(path,revisionString);
      for(iEntry = 0; iEntry < nEntry; iEntry++) {
         path.SetFormatted("Entry[%d]/User", iEntry + 1);
         xmlIn->GetPathValue(path,user[iEntry]);
         path.SetFormatted("Entry[%d]/Host", iEntry + 1);
         xmlIn->GetPathValue(path,host[iEntry]);
         path.SetFormatted("Entry[%d]/Directory", iEntry + 1);
         xmlIn->GetPathValue(path,directory[iEntry]);
         path.SetFormatted("Entry[%d]/LastCompile", iEntry + 1);
         xmlIn->GetPathValue(path,lastcompile[iEntry]);
         if (user[iEntry] == user[nEntry] &&
             host[iEntry] == host[nEntry] &&
             directory[iEntry] == directory[nEntry]) {
            lastcompile[iEntry] = lastcompile[nEntry];
            foundIdenticalEntry = kTRUE;
         }
      }

      //
      // Writing XML
      //

      if (
         // Ryu
         user[nEntry] == "sawada" ||
         user[nEntry] == "ryu" ||
         // Matthias
         user[nEntry] == "schneebeli_m" ||
         user[nEntry] == "egger_j" ||
         // Shuei
         user[nEntry] == "shuei" ||
         user[nEntry] == "yamada" ||
#if 0
         // Meg
         user[nEntry] == "meg" ||
         user[nEntry] == "Administrator" ||
#endif
         0) {

         ROMEXML::SuppressWritingDate();
         auto_ptr<ROMEXML> xmlOut(new ROMEXML());
         xmlOut->OpenFileForWrite(xmlFileName);
         xmlOut->SetTranslate(0);
         xmlOut->WriteElement("Revision", revisionString.Data());
         for(iEntry = 0; iEntry < nEntry; iEntry++) {
            xmlOut->StartElement("Entry");
            xmlOut->WriteElement("User", user[iEntry].Data());
            xmlOut->WriteElement("Host", host[iEntry].Data());
            xmlOut->WriteElement("Directory", directory[iEntry].Data());
            xmlOut->WriteElement("LastCompile", lastcompile[iEntry].Data());
            xmlOut->EndElement();
         }
         if (!foundIdenticalEntry) {
            xmlOut->StartElement("Entry");
            xmlOut->WriteElement("User", user[nEntry].Data());
            xmlOut->WriteElement("Host", host[nEntry].Data());
            xmlOut->WriteElement("Directory", directory[nEntry].Data());
            xmlOut->WriteElement("LastCompile", lastcompile[nEntry].Data());
            xmlOut->EndElement();
         }
         xmlOut->EndDocument();
      }
      ParseSVNKeyword(revisionString);
      revisionNumber = revisionString.ToInteger();
   }
   else {
      cerr<<"Error: Revision number in include/ROMEVersion.h will not be correct."<<endl;
      revisionNumber = 0;
   }

   ROMEString hfile = "$(ROMESYS)/include/";
   gSystem->ExpandPathName(hfile);
   hfile.AppendFormatted("ROMEVersion.h");
   //
   // Reading ROMEVersion.h
   //
   ROMEString fileBuffer;
   ifstream originalFile(hfile.Data());
   if (originalFile.good()) {
      fileBuffer.ReadFile(originalFile);
   }
   originalFile.close();

   //
   // Writing ROMEVersion.h
   //

   ROMEString buffer;
//   cout << "9" << endl;

   // current time
   UInt_t year;
   UInt_t month;
   UInt_t day;
   UInt_t hour;
   UInt_t min;
   UInt_t sec;
   timestamp.Set();
   timestamp.GetDate(kTRUE, 0, &year, &month, &day);
   timestamp.GetTime(kTRUE, 0, &hour, &min, &sec);

   // prepare new file.
   buffer.Resize(0);
   buffer.AppendFormatted("#ifndef ROMEVersion\n");
   buffer.AppendFormatted("#define ROMEVersion\n");
   buffer.AppendFormatted("\n");
   buffer.AppendFormatted("/* Version information automatically generated by installer. */\n");
   buffer.AppendFormatted("\n");
   buffer.AppendFormatted("/*\n");
   buffer.AppendFormatted(" * These macros can be used in the following way:\n");
   buffer.AppendFormatted(" *\n");
   buffer.AppendFormatted(" *    #if ROME_VERSION_CODE >= ROME_VERSION(2,5)\n");
   buffer.AppendFormatted(" *    #   include <newheader.h>\n");
   buffer.AppendFormatted(" *    #else\n");
   buffer.AppendFormatted(" *    #   include <oldheader.h>\n");
   buffer.AppendFormatted(" *    #endif\n");
   buffer.AppendFormatted(" *\n");
   buffer.AppendFormatted("*/\n");
   buffer.AppendFormatted("\n");
   buffer.AppendFormatted("#define ROME_RELEASE \"%d.%d\"\n", romeMajor, romeMinor);
   buffer.AppendFormatted("#define ROME_REVISION_CODE %d\n", revisionNumber);
   buffer.AppendFormatted("#define ROME_STABLE %d\n", isStableVersion);
/*
   buffer.AppendFormatted("#define ROME_RELEASE_DATE \"%s %2d %d\"\n", monthName[month], day, year);
   buffer.AppendFormatted("#define ROME_RELEASE_TIME \"%02d:%02d:%02d\"\n", hour, min, sec);
*/
   buffer.AppendFormatted("#define ROME_VERSION_CODE %d\n", GetROMEVersion(romeMajor, romeMinor));
   buffer.AppendFormatted("#define ROME_VERSION(a,b) (((a) << 8) + (b))\n");
   buffer.AppendFormatted("\n");
   buffer.AppendFormatted("#endif\n");

   // write file
   if (fileBuffer != buffer) {
      ofstream versionH(hfile.Data());
      if (!versionH.good()) {
         cerr<<"failed to open "<<hfile<<" for write."<<endl;
         return 1;
      }
      versionH<<buffer.Data();
      versionH.close();
   }

   return 0;
}