QString QNativeWifiEngine::getInterfaceFromId(const QString &id) { QMutexLocker locker(&mutex); if (!available()) return QString(); // enumerate interfaces WLAN_INTERFACE_INFO_LIST *interfaceList; DWORD result = local_WlanEnumInterfaces(handle, 0, &interfaceList); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG qDebug("%s: WlanEnumInterfaces failed with error %ld\n", __FUNCTION__, result); #endif return QString(); } for (unsigned int i = 0; i < interfaceList->dwNumberOfItems; ++i) { const WLAN_INTERFACE_INFO &interface = interfaceList->InterfaceInfo[i]; DWORD dataSize; WLAN_CONNECTION_ATTRIBUTES *connectionAttributes; result = local_WlanQueryInterface(handle, &interface.InterfaceGuid, wlan_intf_opcode_current_connection, 0, &dataSize, reinterpret_cast<PVOID *>(&connectionAttributes), 0); if (result != ERROR_SUCCESS) { #ifdef BEARER_MANAGEMENT_DEBUG if (result != ERROR_INVALID_STATE) qDebug("%s: WlanQueryInterface failed with error %ld\n", __FUNCTION__, result); #endif continue; } if (qHash(QLatin1String("WLAN:") + QString::fromWCharArray(connectionAttributes->strProfileName)) == id.toUInt()) { QString guid("{%1-%2-%3-%4%5-%6%7%8%9%10%11}"); guid = guid.arg(interface.InterfaceGuid.Data1, 8, 16, QChar('0')); guid = guid.arg(interface.InterfaceGuid.Data2, 4, 16, QChar('0')); guid = guid.arg(interface.InterfaceGuid.Data3, 4, 16, QChar('0')); for (int i = 0; i < 8; ++i) guid = guid.arg(interface.InterfaceGuid.Data4[i], 2, 16, QChar('0')); local_WlanFreeMemory(connectionAttributes); local_WlanFreeMemory(interfaceList); return guid.toUpper(); } local_WlanFreeMemory(connectionAttributes); } local_WlanFreeMemory(interfaceList); return QString(); }
//----------------------------------------------------------------------------- NS_IMETHODIMP CPlaylistCommandsManager::Withdraw(const nsAString &aCommandsGUID, sbIPlaylistCommands *aCommandObj) { NS_ENSURE_ARG_POINTER(aCommandObj); nsString guid(aCommandsGUID); if (m_publishedCommands[guid] != aCommandObj) return NS_ERROR_FAILURE; m_publishedCommands.erase(guid); return NS_OK; }
std::string FMUCodeGen::generateGUID() { UUID uuid; UuidCreate ( &uuid ); unsigned char * str; UuidToStringA ( &uuid, &str ); std::string guid( ( char* ) str ); guid = "{"+guid+"}"; RpcStringFreeA ( &str ); return guid; }
void InstagramClient::sendComment(QString mediaID, QString comment, QJSValue callback) { QJsonObject json; json["_uid"] = QString::number(currentAccount()->userID()); json["_uuid"] = guid(); json["comment_text"] = comment.trimmed(); QByteArray body = this->getSignedBody(json); QUrl url(QString("https://i.instagram.com/api/v1/media/%1/comment/").arg(mediaID)); executePostRequest(url, body, callback); }
//----------------------------------------------------------------------------- NS_IMETHODIMP CPlaylistCommandsManager::Request(const nsAString &aCommandsGUID, sbIPlaylistCommands **_retval) { nsString guid(aCommandsGUID); sbIPlaylistCommands *dup = NULL; sbIPlaylistCommands *cmds; cmds = m_publishedCommands[guid]; if (cmds) cmds->Duplicate(&dup); *_retval = dup; return NS_OK; }
void Serializer::_setSession() { char szText [1024]; Registry registry; Guid guid(®istry); string guid_value; StringConversion::ToMultiByte(guid.Get().c_str(), guid_value); sprintf_s (szText, "\t<session guid='%s' />\n", guid_value.c_str()); *m_stream << szText; guid.Store(); }
void InstagramClient::deleteComments(QString mediaID, QStringList commentIDs, QJSValue callback) { QJsonObject json; json["_uid"] = QString::number(currentAccount()->userID()); json["_uuid"] = guid(); json["comment_ids_to_delete"] = commentIDs.join(QChar(',')); QByteArray body = this->getSignedBody(json); QUrl url(QString("https://i.instagram.com/api/v1/media/%1/comment/bulk_delete/").arg(mediaID)); executePostRequest(url, body, callback); }
bool CssmSubserviceUid::operator == (const CSSM_SUBSERVICE_UID &otherUid) const { // make sure we don't crash if we get bad data if (&otherUid == 0x0) { return false; } const CssmSubserviceUid &other = CssmSubserviceUid::overlay(otherUid); return subserviceId() == other.subserviceId() && subserviceType() == other.subserviceType() && guid() == other.guid(); }
SimpleSubscriber::SimpleSubscriber(Channel::ptr_t channel, const std::string& publisher_name) : m_channel(channel) { m_consumerQueue = "SimpleSubscriber_"; boost::uuids::random_generator uuid_gen; boost::uuids::uuid guid(uuid_gen()); m_consumerQueue += boost::lexical_cast<std::string>(guid); m_channel->DeclareQueue(m_consumerQueue); m_channel->BindQueue(m_consumerQueue, publisher_name); m_channel->BasicConsume(m_consumerQueue, m_consumerQueue); }
void InstagramClient::unlike(QString mediaID, QJSValue callback) { QJsonObject json; json["module_name"] = QString("feed_timeline"); json["media_id"] = mediaID; json["_uid"] = currentAccount()->userID(); json["_uuid"] = guid(); QByteArray body = this->getSignedBody(json); QUrl url(QString("https://i.instagram.com/api/v1/media/%1/unlike/").arg(mediaID)); executePostRequest(url, body, callback); }
void ResourceManager::_load(xml::ElementPtr _node, const std::string& _file, Version _version) { FactoryManager& factory = FactoryManager::getInstance(); VectorGuid vector_guid; // берем детей и крутимся, основной цикл xml::ElementEnumerator root = _node->getElementEnumerator(); while (root.next(XML_TYPE)) { // парсим атрибуты std::string id, type, name; root->findAttribute("type", type); root->findAttribute("name", name); root->findAttribute("id", id); Guid guid(id); if (!guid.empty()) { if (mResourcesID.find(guid) != mResourcesID.end()) { MYGUI_LOG(Warning, "dublicate resource id " << guid.print()); } } if (mResources.find(name) != mResources.end()) { MYGUI_LOG(Warning, "dublicate resource name '" << name << "'"); } vector_guid.push_back(guid); IObject* object = factory.createObject(XML_TYPE, type); if (object == nullptr) { MYGUI_LOG(Error, "resource type '" << type << "' not found"); continue; } IResourcePtr resource = object->castType<IResource>(); resource->deserialization(root.current(), _version); if (!guid.empty()) mResourcesID[guid] = resource; if (!name.empty()) mResources[name] = resource; } if (!vector_guid.empty()) { mListFileGuid[_file] = vector_guid; } }
int CatalanitzadorPerAWindows::Run(wstring commandLine) { bool impersonated; Registry registry; ApplicationExecutor applicationExecutor; CommandLine commandLineProcessor(applicationExecutor.GetActionsObject()); _initLog(); commandLineProcessor.Process(commandLine); if (commandLineProcessor.GetRunningCheck() == true) { if (_isAlreadyRunning() == true) return RETURN_ERROR; } Guid guid(®istry); guid.Get(); m_serializer.OpenHeader(); m_serializer.Serialize(&guid); guid.Store(); if (_supportedOS() == false || _hasAdminPermissionsDialog() == false) return RETURN_ERROR; impersonated = _warnImpersonateUser(); OleInitialize(0); applicationExecutor.SetSerializer(&m_serializer); Option optionShowSecDlg(OptionSilentInstall, commandLineProcessor.GetSilent()); applicationExecutor.SetOption(optionShowSecDlg); Option optionShowImpersonatedDlg(OptionShowImpersonatedDlg, impersonated); applicationExecutor.SetOption(optionShowImpersonatedDlg); if (commandLineProcessor.GetSilent()) { SilentInstallation silentInstallation; silentInstallation.Run(applicationExecutor); } else { AXRegister(); UIInstallation uiInstallation; uiInstallation.Run(m_hInstance, applicationExecutor); } return applicationExecutor.HasErrors() ? RETURN_ERROR : RETURN_OK; }
void* WCSerializeableObject::GetGUIDAttrib(xercesc::DOMElement *element, const std::string &name, WCSerialDictionary *dictionary) { //Get attribute and node for the name XMLCh* attribName = xercesc::XMLString::transcode( name.c_str() ); //Get the value of the attribute const XMLCh* attribValue = element->getAttribute(attribName); xercesc::XMLString::release(&attribName); //Convert to WCGUID char *str = xercesc::XMLString::transcode(attribValue); WCGUID guid(str); delete str; void* value = dictionary->AddressFromGUID(guid); //Return the value return value; }
SimplePublisher::SimplePublisher(Channel::ptr_t channel, const std::string& publisher_name) : m_channel(channel), m_publisherExchange(publisher_name) { if (m_publisherExchange == "") { m_publisherExchange = "SimplePublisher_"; boost::uuids::random_generator uuid_gen; boost::uuids::uuid guid(uuid_gen()); m_publisherExchange += boost::lexical_cast<std::string>(guid); } m_channel->DeclareExchange(m_publisherExchange, "fanout", false, false, false); }
/*! Composes a string to be used as an href attribute in DITA XML. It is composed of the file name and the UUID separated by a '#'. If this node is a class node, the file name is taken from this node; if this node is a function node, the file name is taken from the parent node of this node. */ QString Node::ditaXmlHref() { QString href; if ((type() == Function) || (type() == Property) || (type() == Variable)) { href = parent()->fileBase(); } else { href = fileBase(); } if (!href.endsWith(".xml")) href += ".xml"; return href + "#" + guid(); }
QString Item::debugInfo() const { QString info; info += QLatin1String("### Item: ###################\n"); if (!title().isNull()) info += QLatin1String("title: #") + title() + QLatin1String("#\n"); if (!link().isNull()) info += QLatin1String("link: #") + link() + QLatin1String("#\n"); if (!description().isNull()) info += QLatin1String("description: #") + description() + QLatin1String("#\n"); if (!content().isNull()) info += QLatin1String("content: #") + content() + QLatin1String("#\n"); if (!author().isNull()) info += QLatin1String("author: #") + author() + QLatin1String("#\n"); if (!comments().isNull()) info += QLatin1String("comments: #") + comments() + QLatin1String("#\n"); QString dpubdate = dateTimeToString(pubDate()); if (!dpubdate.isNull()) info += QLatin1String("pubDate: #") + dpubdate + QLatin1String("#\n"); if (!guid().isNull()) info += QLatin1String("guid: #") + guid() + QLatin1String("#\n"); if (guidIsPermaLink()) info += QLatin1String("guid is PL: #true#\n"); if (!source().isNull()) info += source().debugInfo(); QList<Category> cats = categories(); for (QList<Category>::ConstIterator it = cats.constBegin(); it != cats.constEnd(); ++it) info += (*it).debugInfo(); QList<Enclosure> encs = enclosures(); for (QList<Enclosure>::ConstIterator it = encs.constBegin(); it != encs.constEnd(); ++it) info += (*it).debugInfo(); info += QLatin1String("### Item end ################\n"); return info; }
bool CssmSubserviceUid::operator < (const CSSM_SUBSERVICE_UID &otherUid) const { if (&otherUid == 0x0) { return false; } const CssmSubserviceUid &other = CssmSubserviceUid::overlay(otherUid); if (subserviceId() < other.subserviceId()) return true; if (subserviceId() > other.subserviceId()) return false; if (subserviceType() < other.subserviceType()) return true; if (subserviceType() > other.subserviceType()) return false; return guid() < other.guid(); }
void SharedBuffer::onMemoryDump(const String& dumpPrefix, WebProcessMemoryDump* memoryDump) const { if (m_buffer.size()) { WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpPrefix + "/shared_buffer"); dump->addScalar("size", "bytes", m_buffer.size()); memoryDump->addSuballocation( dump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); } else { // If there is data in the segments, then it should have been allocated // using fastMalloc. const String dataDumpName = dumpPrefix + "/segments"; auto dump = memoryDump->createMemoryAllocatorDump(dataDumpName); dump->addScalar("size", "bytes", m_size); memoryDump->addSuballocation( dump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName)); } }
void pyVault::UnInvitePlayerToAge( const char * str, uint32_t playerID ) { plAgeInfoStruct info; plUUID guid(str); info.SetAgeInstanceGuid(&guid); if (hsRef<RelVaultNode> rvnLink = VaultGetOwnedAgeLink(&info)) { if (hsRef<RelVaultNode> rvnInfo = rvnLink->GetChildNode(plVault::kNodeType_AgeInfo, 1)) { VaultAgeInfoNode ageInfo(rvnInfo); ageInfo.CopyTo(&info); } } hsRef<NetVaultNode> templateNode = new NetVaultNode; templateNode->SetNodeType(plVault::kNodeType_TextNote); VaultTextNoteNode visitAcc(templateNode); visitAcc.SetNoteType(plVault::kNoteType_UnVisit); visitAcc.SetVisitInfo(info); VaultCreateNode(templateNode, (FVaultCreateNodeCallback)_UninvitePlayerToAge, nil, (void*)playerID); }
bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, uint32 Entry, Unit* owner) { SetMap(cPos.GetMap()); SetPhaseMask(cPos.GetPhaseMask(), false); Team team = owner->GetTypeId() == TYPEID_PLAYER ? ((Player*)owner)->GetTeam() : TEAM_NONE; ObjectGuid guid(HIGHGUID_UNIT, Entry, guidlow); if (!CreateFromProto(guid, Entry, team)) return false; // special model selection case for totems if (owner->GetTypeId() == TYPEID_PLAYER) { if (uint32 modelid_race = sObjectMgr.GetModelForRace(GetNativeDisplayId(), owner->getRaceMask())) SetDisplayId(modelid_race); } cPos.SelectFinalPoint(this); // totem must be at same Z in case swimming caster and etc. if (fabs(cPos.m_pos.z - owner->GetPositionZ() ) > 5.0f) cPos.m_pos.z = owner->GetPositionZ(); if (!cPos.Relocate(this)) return false; //Notify the map's instance data. //Only works if you create the object in it, not if it is moves to that map. //Normally non-players do not teleport to other maps. if (InstanceData* iData = GetMap()->GetInstanceData()) iData->OnCreatureCreate(this); LoadCreatureAddon(); return true; }
wxDisplayImpl *wxDisplayFactoryDirectDraw::CreateDisplay(unsigned n) { wxCHECK_MSG( n < m_displays.size(), NULL, wxT("invalid display index") ); wxDisplayInfoDirectDraw * info = static_cast<wxDisplayInfoDirectDraw *>(m_displays[n]); if ( !info->m_pDD2 ) { IDirectDraw *pDD; GUID guid(info->m_guid); HRESULT hr = (*m_pfnDirectDrawCreate)(&guid, &pDD, NULL); if ( FAILED(hr) || !pDD ) { // what to do?? wxLogApiError(wxT("DirectDrawCreate"), hr); return NULL; } // we got IDirectDraw, but we need IDirectDraw2 hr = pDD->QueryInterface(wxIID_IDirectDraw2, (void **)&info->m_pDD2); pDD->Release(); if ( FAILED(hr) || !info->m_pDD2 ) { wxLogApiError(wxT("IDirectDraw::QueryInterface(IDD2)"), hr); return NULL; } // NB: m_pDD2 will now be only destroyed when m_displays is destroyed // which is ok as we don't want to recreate DD objects all the time } //else: DirectDraw object corresponding to our display already exists return new wxDisplayImplDirectDraw(n, *info, info->m_pDD2); }
/** * This creates a link from this object to 'other' of the given 'linkType'. * * @param linkType The type of the link. * @param other The node to link to. * * @return The link between this and other. */ ChunkLinkPtr EditorChunkItemLinkable::createLink( ChunkLink::Direction linkType, EditorChunkItemLinkable* other) { MF_ASSERT( other ); MF_ASSERT( other != this ); MF_ASSERT( chunkItem()->pOwnSect() ); MF_ASSERT( other->chunkItem()->pOwnSect() ); ChunkLinkPtr result = NULL; switch (linkType) { case ChunkLink::DIR_NONE: if (isLinkedTo( other->guid() )) removeLink( other ); if (other->isLinkedTo( guid() )) other->removeLink( this ); result = NULL; break; case ChunkLink::DIR_START_END: result = setLink( other, true ); other->setLink( this, false ); break; case ChunkLink::DIR_END_START: result = setLink( other, false ); other->setLink( this, true ); break; case ChunkLink::DIR_BOTH: result = setLink( other, true ); other->setLink( this, true ); break; } return result; }
/* passwdent() Read the password file looking for current user's entry. Fill in the status structure. Has the (dangerous) side effect of giving a value to getenv("HOME"). */ passwdent() { register char *u; register struct passwd *pwd; #ifdef CRN register struct gecos *gcos; #endif pwd = PwdCurrent(); if(pwd == NULL){ err("Bad uid/username\n"); return; } strcpy(status.localname,pwd->pw_name); status.muid = guid(pwd->pw_uid,pwd->pw_gid); status.mgid = pwd->pw_gid; #ifdef CRN if( (gcos=pwgecos( pwd->pw_gecos) ) == NULL ) strcpy( status.jobno, MAGICCRN ); else { if( debugflg ) debug( "crn found = %s\n", gcos->gc_crn ); if( isalpha( gcos->gc_crn[0] ) || isdigit( gcos->gc_crn[0] ) ) strcpy( status.jobno, gcos->gc_crn ); else strcpy( status.jobno, MAGICCRN ); } #else strcpy( status.jobno, "XYZZ" ); #endif strcpy(status.dir,pwd->pw_dir); strcpy(shomedir,pwd->pw_dir); /* side effect */ u = pwd->pw_shell; if(u[0] == 0 || strcmp(u,"/bin/sbash") == 0)u= Bsh; strcpy(status.loginshell,u); }
bool ChatHandler::HandleTargetAndDeleteObjectCommand(char *args) { Player* pl = m_session->GetPlayer(); QueryResult *result; uint32 id = args && *args ? atoi((char*)args) : 0; float distance = 100; // should be ok as max. if(id) { // copied from HandleGameObjectNearCommand result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' AND id = '%u' ORDER BY order_", pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance, id); } else { // copied from HandleGameObjectNearCommand, added id = '...' to WHERE part result = WorldDatabase.PQuery("SELECT guid, id, position_x, position_y, position_z, map, " "(POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) AS order_ " "FROM gameobject WHERE map='%u' AND (POW(position_x - '%f', 2) + POW(position_y - '%f', 2) + POW(position_z - '%f', 2)) <= '%f' ORDER BY order_", pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(), pl->GetMapId(), pl->GetPositionX(), pl->GetPositionY(), pl->GetPositionZ(),distance*distance); } if (!result) { SendSysMessage("Nothing found!"); return true; } Field *fields = result->Fetch(); uint32 guid32 = fields[0].GetUInt32(); id = fields[1].GetUInt32(); float x = fields[2].GetFloat(); float y = fields[3].GetFloat(); float z = fields[4].GetFloat(); float o = fields[5].GetFloat(); int mapid = fields[6].GetUInt16(); delete result; const GameObjectInfo *goI = sObjectMgr.GetGameObjectInfo(id); if (!goI) { PSendSysMessage(LANG_GAMEOBJECT_NOT_EXIST,id); return false; } ObjectGuid guid(HIGHGUID_GAMEOBJECT, id, guid32); GameObject* obj = m_session->GetPlayer()->GetMap()->GetGameObject(guid); if(!obj) { PSendSysMessage("Game Object (GUID: %u) not found", guid32); return true; } ObjectGuid owner_guid = obj->GetOwnerGuid(); if(!owner_guid.IsEmpty()) { Unit* owner = ObjectAccessor::Instance().GetUnit(*m_session->GetPlayer(),owner_guid); if(!owner && !owner_guid.IsPlayer()) { PSendSysMessage("Game Object (GUID: %u) have references in not found creature %u GO list, can't be deleted.", owner_guid.GetCounter(), obj->GetGUIDLow()); return true; } owner->RemoveGameObject(obj,false); } obj->Delete(); obj->DeleteFromDB(); PSendSysMessage("Game Object (GUID: %u) [%s] removed", obj->GetGUIDLow(),goI->name); return true; }
void plSceneInputInterface::ILinkOffereeToAge() { // check vault to see if we've got an instance of the offered age now, if not create one and wait until we get a reply... plAgeInfoStruct info; info.SetAgeFilename(fOfferedAgeFile); info.SetAgeInstanceName(fOfferedAgeInstance); bool isAgeInstanceGuidSet = fAgeInstanceGuid.IsSet(); plAgeLinkStruct link; if (isAgeInstanceGuidSet) { info.SetAgeInstanceGuid(&fAgeInstanceGuid); link.GetAgeInfo()->CopyFrom(&info); fAgeInstanceGuid.Clear(); } else if (!VaultGetOwnedAgeLink(&info, &link)) { // We must have an owned copy of the age before we can offer it, so make one now plUUID guid(GuidGenerate()); info.SetAgeInstanceGuid(&guid); std::string title; std::string desc; unsigned nameLen = plNetClientMgr::GetInstance()->GetPlayerName().GetSize(); if (plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 's' || plNetClientMgr::GetInstance()->GetPlayerName().CharAt(nameLen - 1) == 'S') { xtl::format( title, "%s'", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); xtl::format( desc, "%s' %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); } else { xtl::format( title, "%s's", plNetClientMgr::GetInstance()->GetPlayerName().c_str() ); xtl::format( desc, "%s's %s", plNetClientMgr::GetInstance()->GetPlayerName().c_str(), link.GetAgeInfo()->GetAgeInstanceName() ); } info.SetAgeUserDefinedName( title.c_str() ); info.SetAgeDescription( desc.c_str() ); link.GetAgeInfo()->CopyFrom(&info); if (!VaultRegisterOwnedAgeAndWait(&link)) { // failed to become an owner of the age for some reason, offer cannot continue return; } } else if (RelVaultNode * linkNode = VaultGetOwnedAgeLinkIncRef(&info)) { // We have the age in our AgesIOwnFolder. If its volatile, dump it for the new one. VaultAgeLinkNode linkAcc(linkNode); if (linkAcc.volat) { if (VaultUnregisterOwnedAgeAndWait(link.GetAgeInfo())) { plUUID guid(GuidGenerate()); link.GetAgeInfo()->SetAgeInstanceGuid(&guid); VaultRegisterOwnedAgeAndWait(&link); } } linkNode->DecRef(); } if (fSpawnPoint) { plSpawnPointInfo spawnPoint; spawnPoint.SetName(fSpawnPoint); link.SetSpawnPoint(spawnPoint); } // We now own the age, offer it if (0 == stricmp(fOfferedAgeFile, kPersonalAgeFilename)) plNetLinkingMgr::GetInstance()->OfferLinkToPlayer(&link, fOffereeID, fManager->GetKey()); else plNetLinkingMgr::GetInstance()->LinkPlayerToAge(&link, fOffereeID); if (!fPendingLink && stricmp(fOfferedAgeFile, kPersonalAgeFilename)) { // tell our local dialog to pop up again... plKey avKey = plNetClientMgr::GetInstance()->GetLocalPlayerKey(); ISendOfferNotification(avKey, 0, false); // make them clickable again(in case they come back?) //IManageIgnoredAvatars(fOffereeKey, false); fBookMode = kNotOffering; fOffereeKey = nil; fPendingLink = false; } else // this is a yeesha book link, must wait for multistage callbacks { // commented out until after 0.9 fBookMode = kOfferLinkPending; fPendingLink = true; // fBookMode = kNotOffering; // fOffereeKey = nil; // fPendingLink = false; // ISendAvatarDisabledNotification(true); } }
// GenerateVCXProj //------------------------------------------------------------------------------ const AString & VSProjectGenerator::GenerateVCXProj( const AString & projectFile, const Array< VSProjectConfig > & configs, const Array< VSProjectFileType > & fileTypes ) { ASSERT( !m_ProjectName.IsEmpty() ); // needed for valid guid generation // preallocate to avoid re-allocations m_Tmp.SetReserved( MEGABYTE ); m_Tmp.SetLength( 0 ); // determine folder for project const char * lastSlash = projectFile.FindLast( NATIVE_SLASH ); AStackString<> projectBasePath( projectFile.Get(), lastSlash ? lastSlash + 1 : projectFile.Get() ); // header Write( "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" ); Write( "<Project DefaultTargets=\"Build\" ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n" ); // Project Configurations { Write( " <ItemGroup Label=\"ProjectConfigurations\">\n" ); const VSProjectConfig * const cEnd = configs.End(); for ( const VSProjectConfig * cIt = configs.Begin(); cIt!=cEnd; ++cIt ) { Write( " <ProjectConfiguration Include=\"%s|%s\">\n", cIt->m_Config.Get(), cIt->m_Platform.Get() ); Write( " <Configuration>%s</Configuration>\n", cIt->m_Config.Get() ); Write( " <Platform>%s</Platform>\n", cIt->m_Platform.Get() ); Write( " </ProjectConfiguration>\n" ); } Write( " </ItemGroup>\n" ); } // files { Write(" <ItemGroup>\n" ); const AString * const fEnd = m_Files.End(); for ( const AString * fIt = m_Files.Begin(); fIt!=fEnd; ++fIt ) { const char * fileName = fIt->BeginsWithI( projectBasePath ) ? fIt->Get() + projectBasePath.GetLength() : fIt->Get(); const char * fileType = nullptr; const VSProjectFileType * const end = fileTypes.End(); for ( const VSProjectFileType * it=fileTypes.Begin(); it!=end; ++it ) { if ( AString::MatchI( it->m_Pattern.Get(), fileName ) ) { fileType = it->m_FileType.Get(); break; } } if ( fileType ) { Write( " <CustomBuild Include=\"%s\">\n", fileName ); Write( " <FileType>%s</FileType>\n", fileType ); Write( " </CustomBuild>\n" ); } else { Write( " <CustomBuild Include=\"%s\" />\n", fileName ); } } Write(" </ItemGroup>\n" ); } // References { Write(" <ItemGroup>\n" ); { // Project References const AString * const end = m_ProjectReferences.End(); for ( const AString * it = m_ProjectReferences.Begin(); it != end; ++it ) { AStackString<> proj( *it ); const char * pipe = proj.Find( '|' ); if ( pipe ) { proj.SetLength( (uint32_t)( pipe - proj.Get() ) ); AStackString<> guid( pipe + 1 ); Write( " <ProjectReference Include=\"%s\">\n", proj.Get() ); Write( " <Project>%s</Project>\n", guid.Get() ); Write( " </ProjectReference>\n" ); } else { Write( " <ProjectReference Include=\"%s\" />\n", proj.Get() ); } } } { // References const AString * const end = m_References.End(); for ( const AString * it = m_References.Begin(); it != end; ++it ) { Write( " <Reference Include=\"%s\" />\n", it->Get() ); } } Write(" </ItemGroup>\n" ); } // GUID : use user provided one if available, otherwise generate one deterministically AStackString<> guid; if ( m_ProjectGuid.IsEmpty() ) { FormatDeterministicProjectGUID( guid, m_ProjectName ); } else { guid = m_ProjectGuid; } // Globals Write( " <PropertyGroup Label=\"Globals\">\n" ); WritePGItem( "RootNamespace", m_RootNamespace ); WritePGItem( "ProjectGuid", guid ); WritePGItem( "DefaultLanguage", m_DefaultLanguage ); WritePGItem( "Keyword", AStackString<>( "MakeFileProj" ) ); WritePGItem( "ApplicationEnvironment", m_ApplicationEnvironment ); Write( " </PropertyGroup>\n" ); // Default props Write( " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n" ); // Configurations { const VSProjectConfig * const cEnd = configs.End(); for ( const VSProjectConfig * cIt = configs.Begin(); cIt!=cEnd; ++cIt ) { Write( " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\" Label=\"Configuration\">\n", cIt->m_Config.Get(), cIt->m_Platform.Get() ); Write( " <ConfigurationType>Makefile</ConfigurationType>\n" ); Write( " <UseDebugLibraries>false</UseDebugLibraries>\n" ); WritePGItem( "PlatformToolset", cIt->m_PlatformToolset ); WritePGItem( "LocalDebuggerCommandArguments", cIt->m_LocalDebuggerCommandArguments ); WritePGItem( "LocalDebuggerCommand", cIt->m_LocalDebuggerCommand ); WritePGItem( "LocalDebuggerEnvironment", cIt->m_LocalDebuggerEnvironment ); Write( " </PropertyGroup>\n" ); } } // Imports { Write( " <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n" ); Write( " <ImportGroup Label=\"ExtensionSettings\">\n" ); Write( " </ImportGroup>\n" ); } // Property Sheets { const VSProjectConfig * const cEnd = configs.End(); for ( const VSProjectConfig * cIt = configs.Begin(); cIt!=cEnd; ++cIt ) { Write( " <ImportGroup Label=\"PropertySheets\" Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\">\n", cIt->m_Config.Get(), cIt->m_Platform.Get() ); Write( " <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n" ); Write( " </ImportGroup>\n" ); } } // User macros Write( " <PropertyGroup Label=\"UserMacros\" />\n" ); // Property Group { const VSProjectConfig * const cEnd = configs.End(); for ( const VSProjectConfig * cIt = configs.Begin(); cIt!=cEnd; ++cIt ) { Write( " <PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\">\n", cIt->m_Config.Get(), cIt->m_Platform.Get() ); WritePGItem( "NMakeBuildCommandLine", cIt->m_BuildCommand ); WritePGItem( "NMakeReBuildCommandLine", cIt->m_RebuildCommand ); WritePGItem( "NMakeCleanCommandLine", cIt->m_CleanCommand ); WritePGItem( "NMakeOutput", cIt->m_Output ); const ObjectListNode * oln = nullptr; if ( cIt->m_PreprocessorDefinitions.IsEmpty() || cIt->m_IncludeSearchPath.IsEmpty() ) { oln = ProjectGeneratorBase::FindTargetForIntellisenseInfo( cIt->m_Target ); } if ( cIt->m_PreprocessorDefinitions.IsEmpty() == false ) { WritePGItem( "NMakePreprocessorDefinitions", cIt->m_PreprocessorDefinitions ); } else { if ( oln ) { Array< AString > defines; ProjectGeneratorBase::ExtractIntellisenseOptions( oln->GetCompilerArgs(), "/D", "-D", defines, false ); AStackString<> definesStr; ProjectGeneratorBase::ConcatIntellisenseOptions( defines, definesStr, nullptr, ";" ); WritePGItem( "NMakePreprocessorDefinitions", definesStr ); } } if ( cIt->m_IncludeSearchPath.IsEmpty() == false ) { WritePGItem( "NMakeIncludeSearchPath", cIt->m_IncludeSearchPath ); } else { if ( oln ) { Array< AString > includePaths; ProjectGeneratorBase::ExtractIntellisenseOptions( oln->GetCompilerArgs(), "/I", "-I", includePaths, false ); for ( AString & include : includePaths ) { AStackString<> fullIncludePath; NodeGraph::CleanPath( include, fullIncludePath ); // Expand to full path - TODO:C would be better to be project relative include = fullIncludePath; } AStackString<> includePathsStr; ProjectGeneratorBase::ConcatIntellisenseOptions( includePaths, includePathsStr, nullptr, ";" ); WritePGItem( "NMakeIncludeSearchPath", includePathsStr ); } } WritePGItem( "NMakeForcedIncludes", cIt->m_ForcedIncludes ); WritePGItem( "NMakeAssemblySearchPath", cIt->m_AssemblySearchPath ); WritePGItem( "NMakeForcedUsingAssemblies", cIt->m_ForcedUsingAssemblies ); WritePGItem( "AdditionalOptions", cIt->m_AdditionalOptions ); WritePGItem( "Xbox360DebuggerCommand", cIt->m_Xbox360DebuggerCommand ); WritePGItem( "DebuggerFlavor", cIt->m_DebuggerFlavor ); WritePGItem( "AumidOverride", cIt->m_AumidOverride ); WritePGItem( "LocalDebuggerWorkingDirectory", cIt->m_LocalDebuggerWorkingDirectory ); WritePGItem( "IntDir", cIt->m_IntermediateDirectory ); WritePGItem( "OutDir", cIt->m_OutputDirectory ); WritePGItem( "LayoutDir", cIt->m_LayoutDir ); WritePGItem( "LayoutExtensionFilter", cIt->m_LayoutExtensionFilter ); Write( " </PropertyGroup>\n" ); } } // ItemDefinition Groups { const VSProjectConfig * const cEnd = configs.End(); for ( const VSProjectConfig * cIt = configs.Begin(); cIt!=cEnd; ++cIt ) { Write( " <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='%s|%s'\">\n", cIt->m_Config.Get(), cIt->m_Platform.Get() ); Write( " <BuildLog>\n" ); Write( " <Path />\n" ); Write( " </BuildLog>\n" ); if ( ( !cIt->m_DeploymentType.IsEmpty() ) || ( !cIt->m_DeploymentFiles.IsEmpty() ) ) { Write( " <Deploy>\n" ); WritePGItem( "DeploymentType", cIt->m_DeploymentType ); WritePGItem( "DeploymentFiles", cIt->m_DeploymentFiles ); Write( " </Deploy>\n" ); } Write( " </ItemDefinitionGroup>\n" ); } } // footer Write(" <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n" ); Write(" <ImportGroup Label=\"ExtensionTargets\">\n" ); Write(" </ImportGroup>\n" ); Write(" <Import Condition=\"'$(ConfigurationType)' == 'Makefile' and Exists('$(VCTargetsPath)\\Platforms\\$(Platform)\\SCE.Makefile.$(Platform).targets')\" Project=\"$(VCTargetsPath)\\Platforms\\$(Platform)\\SCE.Makefile.$(Platform).targets\" />\n"); Write( "</Project>" ); // carriage return at end m_OutputVCXProj = m_Tmp; return m_OutputVCXProj; }
AccountOpResult AccountMgr::DeleteAccount(uint32 accountId) { // Check if accounts exists PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_SEL_ACCOUNT_BY_ID); stmt->setUInt32(0, accountId); PreparedQueryResult result = LoginDatabase.Query(stmt); if (!result) return AccountOpResult::AOR_NAME_NOT_EXIST; // Obtain accounts characters stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID); stmt->setUInt32(0, accountId); result = CharacterDatabase.Query(stmt); if (result) { do { ObjectGuid guid(HIGHGUID_PLAYER, (*result)[0].GetUInt32()); // Kick if player is online if (Player* p = ObjectAccessor::FindConnectedPlayer(guid)) { WorldSession* s = p->GetSession(); s->KickPlayer(); // mark session to remove at next session list update s->LogoutPlayer(false); // logout player without waiting next session list update } Player::DeleteFromDB(guid, accountId, false); // no need to update realm characters } while (result->NextRow()); } // table realm specific but common for all characters of account for realm stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_TUTORIALS); stmt->setUInt32(0, accountId); CharacterDatabase.Execute(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_ACCOUNT_DATA); stmt->setUInt32(0, accountId); CharacterDatabase.Execute(stmt); stmt = CharacterDatabase.GetPreparedStatement(CHAR_DEL_CHARACTER_BAN); stmt->setUInt32(0, accountId); CharacterDatabase.Execute(stmt); SQLTransaction trans = LoginDatabase.BeginTransaction(); stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT); stmt->setUInt32(0, accountId); trans->Append(stmt); stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_ACCESS); stmt->setUInt32(0, accountId); trans->Append(stmt); stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_REALM_CHARACTERS); stmt->setUInt32(0, accountId); trans->Append(stmt); stmt = LoginDatabase.GetPreparedStatement(LOGIN_DEL_ACCOUNT_BANNED); stmt->setUInt32(0, accountId); trans->Append(stmt); LoginDatabase.CommitTransaction(trans); return AccountOpResult::AOR_OK; }
nsresult sbLocalDatabaseLibraryFactory::InitalizeLibrary(nsIFile* aDatabaseFile, const nsAString &aResourceGUID) { nsresult rv; PRInt32 dbOk; nsCOMPtr<nsIFile> parentDirectory; rv = aDatabaseFile->GetParent(getter_AddRefs(parentDirectory)); NS_ENSURE_SUCCESS(rv, rv); PRBool parentExists; rv = parentDirectory->Exists(&parentExists); NS_ENSURE_SUCCESS(rv, rv); if (!parentExists) { rv = CreateDirectory(parentDirectory); NS_ENSURE_SUCCESS(rv, rv); } PRBool parentIsWritable = IsDirectoryWritable(parentDirectory); NS_ENSURE_TRUE(parentIsWritable, NS_ERROR_FILE_ACCESS_DENIED); // Now that we know we have appropriate permissions make a new query. nsCOMPtr<sbIDatabaseQuery> query = do_CreateInstance(SONGBIRD_DATABASEQUERY_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = query->SetAsyncQuery(PR_FALSE); NS_ENSURE_SUCCESS(rv, rv); rv = SetQueryDatabaseFile(query, aDatabaseFile); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIURI> schemaURI; rv = NS_NewURI(getter_AddRefs(schemaURI), NS_LITERAL_CSTRING(SCHEMA_URL)); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIInputStream> input; rv = NS_OpenURI(getter_AddRefs(input), schemaURI); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIConverterInputStream> converterStream = do_CreateInstance("@mozilla.org/intl/converter-input-stream;1", &rv); NS_ENSURE_SUCCESS(rv, rv); rv = converterStream->Init(input, "UTF-8", CONVERTER_BUFFER_SIZE, nsIConverterInputStream:: DEFAULT_REPLACEMENT_CHARACTER); NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr<nsIUnicharInputStream> unichar = do_QueryInterface(converterStream, &rv); NS_ENSURE_SUCCESS(rv, rv); PRUint32 read; nsString response, result; rv = unichar->ReadString(PR_UINT32_MAX, result, &read); NS_ENSURE_SUCCESS(rv, rv); NS_ASSERTION(read, "Schema file zero bytes?"); while (read > 0) { response.Append(result); rv = unichar->ReadString(PR_UINT32_MAX, result, &read); NS_ENSURE_SUCCESS(rv, rv); } rv = unichar->Close(); NS_ENSURE_SUCCESS(rv, rv); NS_NAMED_LITERAL_STRING(colonNewline, ";\n"); PRInt32 posStart = 0; PRInt32 posEnd = response.Find(colonNewline, posStart); while (posEnd >= 0) { rv = query->AddQuery(Substring(response, posStart, posEnd - posStart)); NS_ENSURE_SUCCESS(rv, rv); posStart = posEnd + 2; posEnd = response.Find(colonNewline, posStart); } rv = query->Execute(&dbOk); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(dbOk == 0, NS_ERROR_FAILURE); nsString guid(aResourceGUID); if(guid.IsEmpty()) { // Create a resource guid for this database. nsCOMPtr<nsIUUIDGenerator> uuidGen = do_GetService("@mozilla.org/uuid-generator;1", &rv); NS_ENSURE_SUCCESS(rv, rv); nsID id; rv = uuidGen->GenerateUUIDInPlace(&id); NS_ENSURE_SUCCESS(rv, rv); char guidChars[NSID_LENGTH]; id.ToProvidedString(guidChars); guid = NS_ConvertASCIItoUTF16(nsDependentCString(guidChars + 1, NSID_LENGTH - 3)); } // Insert the guid into the database. nsCOMPtr<sbISQLInsertBuilder> insert = do_CreateInstance(SB_SQLBUILDER_INSERT_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = insert->SetIntoTableName(NS_LITERAL_STRING("library_metadata")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("name")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("value")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(NS_LITERAL_STRING("resource-guid")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(guid); NS_ENSURE_SUCCESS(rv, rv); nsAutoString sql; rv = insert->ToString(sql); NS_ENSURE_SUCCESS(rv, rv); rv = query->ResetQuery(); NS_ENSURE_SUCCESS(rv, rv); rv = query->AddQuery(sql); NS_ENSURE_SUCCESS(rv, rv); rv = query->Execute(&dbOk); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(dbOk == 0, NS_ERROR_FAILURE); nsString now; sbLocalDatabaseLibrary::GetNowString(now); nsCOMPtr<nsIURI> fileURI; rv = NS_NewFileURI(getter_AddRefs(fileURI), aDatabaseFile); NS_ENSURE_SUCCESS(rv, rv); nsCString uriSpec; rv = fileURI->GetSpec(uriSpec); NS_ENSURE_SUCCESS(rv, rv); // Add the default library media item properties insert = do_CreateInstance(SB_SQLBUILDER_INSERT_CONTRACTID, &rv); NS_ENSURE_SUCCESS(rv, rv); rv = insert->SetIntoTableName(NS_LITERAL_STRING("library_media_item")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("guid")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(guid); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("created")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(now); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("updated")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(now); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("content_url")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueString(NS_ConvertUTF8toUTF16(uriSpec)); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("hidden")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueLong(0); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddColumn(NS_LITERAL_STRING("is_list")); NS_ENSURE_SUCCESS(rv, rv); rv = insert->AddValueLong(0); NS_ENSURE_SUCCESS(rv, rv); rv = insert->ToString(sql); NS_ENSURE_SUCCESS(rv, rv); rv = query->ResetQuery(); NS_ENSURE_SUCCESS(rv, rv); rv = query->AddQuery(sql); NS_ENSURE_SUCCESS(rv, rv); rv = query->Execute(&dbOk); NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_TRUE(dbOk == 0, NS_ERROR_FAILURE); return NS_OK; }
VRNamedID::VRNamedID() { ID = guid(); }
bool ManagerApp::CheckManagerDB() { int version_groups = DB_MANAGER_VERSION_GROUPS; int version_packages = DB_MANAGER_VERSION_PACKAGES; int version_authorlist = DB_MANAGER_VERSION_AUTHORLIST; int version_packagelist = DB_MANAGER_VERSION_PACKAGELIST; int version_packagelist_authors = DB_MANAGER_VERSION_PACKAGELIST_AUTHORS; int version_packagelist_warnings = DB_MANAGER_VERSION_PACKAGELIST_WARNINGS; wxSQLite3StatementBuffer temp; m_managerdb.Open(m_appdir.GetPath(wxPATH_GET_SEPARATOR | wxPATH_GET_VOLUME) + wxT("manager.db")); if (!m_managerdb.TableExists(wxT("versions"))) { m_managerdb.ExecuteUpdate(wxT("create table versions(tablename char[30], version int);")); temp.Format("insert into versions values ('groups', %d);", version_groups); m_managerdb.ExecuteUpdate(temp); temp.Format("insert into versions values ('packages', %d);", version_packages); m_managerdb.ExecuteUpdate(temp); temp.Format("insert into versions values ('authorlist', %d);", version_authorlist); m_managerdb.ExecuteUpdate(temp); temp.Format("insert into versions values ('packagelist', %d);", version_packagelist); m_managerdb.ExecuteUpdate(temp); temp.Format("insert into versions values ('packagelist_authors', %d);", version_packagelist_authors); m_managerdb.ExecuteUpdate(temp); temp.Format("insert into versions values ('packagelist_warnings', %d);", version_packagelist_warnings); m_managerdb.ExecuteUpdate(temp); } else { version_groups = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'groups';")); version_packages = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'packages';")); version_authorlist = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'authorlist';")); version_packagelist = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'packagelist';")); version_packagelist_authors = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'packagelist_authors';")); version_packagelist_warnings = m_managerdb.ExecuteScalar(wxT("select version from versions where tablename = 'packagelist_warnings';")); } if ((version_groups > DB_MANAGER_VERSION_GROUPS) || (version_packages > DB_MANAGER_VERSION_PACKAGES) || (version_authorlist > DB_MANAGER_VERSION_AUTHORLIST) || (version_packagelist > DB_MANAGER_VERSION_PACKAGELIST) || (version_packagelist_authors > DB_MANAGER_VERSION_PACKAGELIST_AUTHORS) || (version_packagelist_warnings > DB_MANAGER_VERSION_PACKAGELIST_WARNINGS)) { wxLogError(_("Manager database modified by a newer version of this application.")); return false; } if (!m_managerdb.TableExists(wxT("groups"))) { m_managerdb.ExecuteUpdate(wxT("create table groups(name text, guid text);")); } if (!m_managerdb.TableExists(wxT("packages"))) { m_managerdb.ExecuteUpdate(wxT("create table packages(name text, guid text, file text, version text);")); } if (!m_managerdb.TableExists(wxT("authorlist"))) { m_managerdb.ExecuteUpdate(wxT("create table authorlist(name text, guid text, official int);")); wxFileSystem fs; m_managerdb.Begin(); try { xmlcpp::cXmlDoc xdoc(wxString(MEMORY_PREFIX RES_XML_AUTHORS).mb_str(wxConvUTF8), NULL); if (xdoc.ok()) { xmlcpp::cXmlNode child(xdoc.getRoot().children()); while (child.ok()) { if (child.name() == "author") { wxString name(child.getPropVal("name").c_str(), wxConvUTF8); name.Trim(); name.Trim(true); wxString guid(child.getPropVal("guid").c_str(), wxConvUTF8); guid.Trim(); guid.Trim(true); if (name.IsEmpty() || guid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in author list xml.")); return false; } temp.Format("insert into authorlist values ('%q', '%q', 1);", name.mb_str(wxConvUTF8).data(), guid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); } child.go_next(); } } } catch (std::exception& e) { wxLogError(wxString(e.what(), wxConvUTF8)); } /* std::auto_ptr<wxFSFile> inputfsfile(fs.OpenFile(MEMORY_PREFIX RES_XML_AUTHORS, wxFS_READ)); wxXmlDocument doc(*inputfsfile->GetStream()); wxXmlNode* child = doc.GetRoot()->GetChildren(); while (child) { if (child->GetName() == wxT("author")) { wxString name = child->GetPropVal(wxT("name"), wxT("")); name.Trim(); name.Trim(true); wxString guid = child->GetPropVal(wxT("guid"), wxT("")); guid.Trim(); guid.Trim(true); if (name.IsEmpty() || guid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in author list xml.")); return false; } temp.Format("insert into authorlist values ('%q', '%q', 1);", name.mb_str(wxConvUTF8).data(), guid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); } child = child->GetNext(); } */ m_managerdb.Commit(); } if (!m_managerdb.TableExists(wxT("packagelist"))) { m_managerdb.ExecuteUpdate(wxT("create table packagelist(name text, shortname text, guid text, version text, official int);")); } if (!m_managerdb.TableExists(wxT("packagelist_authors"))) { m_managerdb.ExecuteUpdate(wxT("create table packagelist_authors(guid text, authorguid text);")); } if (!m_managerdb.TableExists(wxT("packagelist_warnings"))) { m_managerdb.ExecuteUpdate(wxT("create table packagelist_warnings(guid text, type int, descrition text);")); } if (!m_managerdb.ExecuteScalar(wxT("select count(*) from packagelist;"))) { wxFileSystem fs; m_managerdb.Begin(); try { xmlcpp::cXmlDoc xdoc(wxString(MEMORY_PREFIX RES_XML_PACKAGES).mb_str(wxConvUTF8), NULL); if (xdoc.ok()) { xmlcpp::cXmlNode child(xdoc.getRoot().children()); while (child.ok()) { if (child.name() == "package") { wxString name(child.getPropVal("name").c_str(), wxConvUTF8); name.Trim(); name.Trim(true); wxString shortname(child.getPropVal("shortname").c_str(), wxConvUTF8); shortname.Trim(); shortname.Trim(true); wxString guid(child.getPropVal("guid").c_str(), wxConvUTF8); guid.Trim(); guid.Trim(true); wxString version(child.getPropVal("version").c_str(), wxConvUTF8); version.Trim(); version.Trim(true); if (name.IsEmpty() || guid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (name and/or guid missing).")); return false; } temp.Format("insert into packagelist values ('%q', '%q', '%q', '%q', 1);", name.mb_str(wxConvUTF8).data(), shortname.mb_str(wxConvUTF8).data(), guid.mb_str(wxConvUTF8).data(), version.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); bool haveauthor = false; if (child.hasProp("authorguid")) { wxString authorguid(child.getPropVal("authorguid").c_str(), wxConvUTF8); authorguid.Trim(); authorguid.Trim(true); if (authorguid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (authorguid empty).")); return false; } temp.Format("insert into packagelist_authors values ('%q', '%q');", guid.mb_str(wxConvUTF8).data(), authorguid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); haveauthor = true; } xmlcpp::cXmlNode subchild(child.children()); while(subchild.ok()) { if (subchild.name() == "author") { wxString authorguid(subchild.getPropVal("guid").c_str(), wxConvUTF8); authorguid.Trim(); authorguid.Trim(true); if (authorguid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (author[guid] empty).")); return false; } temp.Format("insert into packagelist_authors values ('%q', '%q');", guid.mb_str(wxConvUTF8).data(), authorguid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); haveauthor = true; } else if (subchild.name() == "warning") { wxString wtype(subchild.getPropVal("type").c_str(), wxConvUTF8); wtype.Trim(); wtype.Trim(true); if (wtype.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (warning[type] empty).")); return false; } wxString desc(subchild.content().c_str(), wxConvUTF8); desc.Trim(); desc.Trim(true); temp.Format("insert into packagelist_warnings values ('%q', '%q', '%q');", guid.mb_str(wxConvUTF8).data(), wtype.mb_str(wxConvUTF8).data(), desc.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); } subchild.go_next(); } if (!haveauthor) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (author missing).")); return false; } } child.go_next(); } } else { wxLogError(_("Failed to open package list xml.")); for (std::vector<xmlcpp::cXmlStructuredError>::const_iterator it = xdoc.getStructuredErrors().begin(); it != xdoc.getStructuredErrors().end(); ++it) wxLogError(wxString(it->message.c_str(), wxConvUTF8)); } } catch (std::exception& e) { wxLogError(wxString(e.what(), wxConvUTF8)); } /* std::auto_ptr<wxFSFile> inputfsfile(fs.OpenFile(MEMORY_PREFIX RES_XML_PACKAGES, wxFS_READ)); wxXmlDocument doc(*inputfsfile->GetStream()); wxXmlNode* child = doc.GetRoot()->GetChildren(); while (child) { if (child->GetName() == wxT("package")) { wxString name = child->GetPropVal(wxT("name"), wxT("")); name.Trim(); name.Trim(true); wxString shortname = child->GetPropVal(wxT("shortname"), wxT("")); shortname.Trim(); shortname.Trim(true); wxString guid = child->GetPropVal(wxT("guid"), wxT("")); guid.Trim(); guid.Trim(true); wxString version = child->GetPropVal(wxT("version"), wxT("0")); version.Trim(); version.Trim(true); if (name.IsEmpty() || guid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (name and/or guid missing).")); return false; } temp.Format("insert into packagelist values ('%q', '%q', '%q', '%q', 1);", name.mb_str(wxConvUTF8).data(), shortname.mb_str(wxConvUTF8).data(), guid.mb_str(wxConvUTF8).data(), version.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); bool haveauthor = false; if (child->HasProp(wxT("authorguid"))) { wxString authorguid = child->GetPropVal(wxT("authorguid"), wxT("")); authorguid.Trim(); authorguid.Trim(true); if (authorguid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (authorguid empty).")); return false; } temp.Format("insert into packagelist_authors values ('%q', '%q');", guid.mb_str(wxConvUTF8).data(), authorguid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); haveauthor = true; } wxXmlNode* subchild = child->GetChildren(); while(subchild) { if (subchild->GetName() == wxT("author")) { wxString authorguid = subchild->GetPropVal(wxT("guid"), wxT("")); authorguid.Trim(); authorguid.Trim(true); if (authorguid.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (author[guid] empty).")); return false; } temp.Format("insert into packagelist_authors values ('%q', '%q');", guid.mb_str(wxConvUTF8).data(), authorguid.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); haveauthor = true; } else if (subchild->GetName() == wxT("warning")) { wxString wtype = subchild->GetPropVal(wxT("type"), wxT("")); wtype.Trim(); wtype.Trim(true); if (wtype.IsEmpty()) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (warning[type] empty).")); return false; } wxString desc = subchild->GetNodeContent(); desc.Trim(); desc.Trim(true); temp.Format("insert into packagelist_warnings values ('%q', '%q', '%q');", guid.mb_str(wxConvUTF8).data(), wtype.mb_str(wxConvUTF8).data(), desc.mb_str(wxConvUTF8).data()); m_managerdb.ExecuteUpdate(temp); } subchild = subchild->GetNext(); } if (!haveauthor) { m_managerdb.Rollback(); wxLogError(_("Error in package list xml (author missing).")); return false; } } child = child->GetNext(); } */ m_managerdb.Commit(); } return true; }