status_t BMediaFiles::RewindRefs(const char* type) { CALLED(); _ClearItems(); TRACE("BMediaFiles::RewindRefs: sending SERVER_GET_MEDIA_FILE_ITEMS for " "type %s\n", type); server_get_media_items_request request; request.team = BPrivate::current_team(); strncpy(request.type, type, B_MEDIA_NAME_LENGTH); server_get_media_items_reply reply; status_t status = QueryServer(SERVER_GET_MEDIA_FILE_ITEMS, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::RewindRefs: failed to rewind refs: %s\n", strerror(status)); return status; } const char* items = (const char*)reply.address; for (int32 i = 0; i < reply.count; i++) { fItems.AddItem(new BString(items + i * B_MEDIA_NAME_LENGTH, B_MEDIA_NAME_LENGTH)); } delete_area(reply.area); fCurrentType = type; fItemIndex = 0; return B_OK; }
status_t BMediaFiles::RewindTypes() { CALLED(); _ClearTypes(); server_get_media_types_request request; request.team = BPrivate::current_team(); server_get_media_types_reply reply; status_t status = QueryServer(SERVER_GET_MEDIA_FILE_TYPES, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::RewindTypes: failed to rewind types: %s\n", strerror(status)); return status; } const char* types = (const char*)reply.address; for (int32 i = 0; i < reply.count; i++) fTypes.AddItem(new BString(types + i * B_MEDIA_NAME_LENGTH)); delete_area(reply.area); fTypeIndex = 0; return B_OK; }
bool pawsPetitionGMWindow::PostSetup() { // Setup this widget to receive messages and commands if ( !psCmdBase::Setup( psengine->GetMsgHandler(), psengine->GetCmdHandler()) ) return false; // Subscribe to certain types of messages (those we want to handle) msgqueue->Subscribe(this, MSGTYPE_PETITION); // Grab the pointer to the petition listbox: petitionList = (pawsListBox*)FindWidget("PetitionList"); petText = (pawsMessageTextBox*)FindWidget("PetitionText"); hasPetInterest = false; petCount = -1; //default value: we didn't receive petitions yet //TODO: this should be removed when autocompletion autocompletes /show // If player is GM, give him the /petition_manage command if ( psengine->GetCelClient()->GetMainPlayer()->GetType() > 20 ) { cmdsource->Subscribe("/managepetitions", this); hasPetInterest = true; //gm are going to want to get informations about the petitions QueryServer(); //Query the server for messages } return true; }
ServerCombinationEdit::ServerCombinationEdit(QWidget* parent, const ServerCombination& c) : ServerCombinationEditBase(parent, 0, false, 0) { nickname_edit->setText(c.nickname); stream_url_edit->setText(c.stream.url); cacert_edit->setText(c.stream.cacert_ssl); insecure_ssl_checkbox->setChecked(c.stream.insecure_ssl); QueryServer(); }
void pawsPetitionGMWindow::Show() { if(psengine->GetCelClient()->GetMainPlayer()->GetType() > 20) //allow access only to who has really access { hasPetInterest = true; pawsWidget::Show(); //show the window QueryServer(); //Query the server for messages } }
status_t DormantNodeManager::FindAddOnPath(BPath* path, media_addon_id id) { server_get_add_on_ref_request request; request.add_on_id = id; server_get_add_on_ref_reply reply; status_t status = QueryServer(SERVER_GET_ADD_ON_REF, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) return status; entry_ref ref = reply.ref; return path->SetTo(&ref); }
status_t PluginManager::CreateDecoder(Decoder** _decoder, const media_format& format) { TRACE("PluginManager::CreateDecoder enter\n"); // get decoder for this format from the server server_get_decoder_for_format_request request; server_get_decoder_for_format_reply reply; request.format = format; status_t ret = QueryServer(SERVER_GET_DECODER_FOR_FORMAT, &request, sizeof(request), &reply, sizeof(reply)); if (ret != B_OK) { printf("PluginManager::CreateDecoder: can't get decoder for format: " "%s\n", strerror(ret)); return ret; } MediaPlugin* plugin = GetPlugin(reply.ref); if (plugin == NULL) { printf("PluginManager::CreateDecoder: GetPlugin failed\n"); return B_ERROR; } DecoderPlugin* decoderPlugin = dynamic_cast<DecoderPlugin*>(plugin); if (decoderPlugin == NULL) { printf("PluginManager::CreateDecoder: dynamic_cast failed\n"); PutPlugin(plugin); return B_ERROR; } // TODO: In theory, one DecoderPlugin could support multiple Decoders, // but this is not yet handled (passing "0" as index/ID). *_decoder = decoderPlugin->NewDecoder(0); if (*_decoder == NULL) { printf("PluginManager::CreateDecoder: NewDecoder() failed\n"); PutPlugin(plugin); return B_ERROR; } TRACE(" created decoder: %p\n", *_decoder); (*_decoder)->fMediaPlugin = plugin; TRACE("PluginManager::CreateDecoder leave\n"); return B_OK; }
BST_ERR_ENUM_UINT8 BST_APP_CEmailIMAP::HandleSelectResp( BST_VOID ) { BST_ERR_ENUM_UINT8 enErrMsg; if ( 0 == BST_OS_MEMCMP( m_pcServerResponse0, "*", 1 ) ) { enErrMsg = QueryServer( m_pcServerResponse1, BST_LIB_StrLen( (BST_CHAR *)m_pcServerResponse1) ); if ( BST_NO_ERROR_MSG == enErrMsg ) { m_lServerState = BST_EMAIL_IMAP_SELECTED; } return enErrMsg; } else { return BST_ERR_UNREACHABLE; } }
status_t PluginManager::CreateEncoder(Encoder** _encoder, const media_codec_info* codecInfo, uint32 flags) { TRACE("PluginManager::CreateEncoder enter\n"); // Get encoder for this codec info from the server server_get_encoder_for_codec_info_request request; server_get_encoder_for_codec_info_reply reply; request.id = codecInfo->id; status_t ret = QueryServer(SERVER_GET_ENCODER_FOR_CODEC_INFO, &request, sizeof(request), &reply, sizeof(reply)); if (ret != B_OK) { printf("PluginManager::CreateEncoder: can't get encoder for codec %s: " "%s\n", codecInfo->pretty_name, strerror(ret)); return ret; } MediaPlugin* plugin = GetPlugin(reply.ref); if (!plugin) { printf("PluginManager::CreateEncoder: GetPlugin failed\n"); return B_ERROR; } EncoderPlugin* encoderPlugin = dynamic_cast<EncoderPlugin*>(plugin); if (encoderPlugin == NULL) { printf("PluginManager::CreateEncoder: dynamic_cast failed\n"); PutPlugin(plugin); return B_ERROR; } *_encoder = encoderPlugin->NewEncoder(*codecInfo); if (*_encoder == NULL) { printf("PluginManager::CreateEncoder: NewEncoder() failed\n"); PutPlugin(plugin); return B_ERROR; } TRACE(" created encoder: %p\n", *_encoder); (*_encoder)->fMediaPlugin = plugin; TRACE("PluginManager::CreateEncoder leave\n"); return B_OK; }
status_t PluginManager::CreateWriter(Writer** writer, const media_file_format& mff, BDataIO* target) { TRACE("PluginManager::CreateWriter enter\n"); // Get the Writer responsible for this media_file_format from the server. server_get_writer_request request; request.internal_id = mff.id.internal_id; server_get_writer_reply reply; status_t ret = QueryServer(SERVER_GET_WRITER_FOR_FORMAT_FAMILY, &request, sizeof(request), &reply, sizeof(reply)); if (ret != B_OK) { printf("PluginManager::CreateWriter: can't get writer for file " "family: %s\n", strerror(ret)); return ret; } MediaPlugin* plugin = GetPlugin(reply.ref); if (plugin == NULL) { printf("PluginManager::CreateWriter: GetPlugin failed\n"); return B_ERROR; } WriterPlugin* writerPlugin = dynamic_cast<WriterPlugin*>(plugin); if (writerPlugin == NULL) { printf("PluginManager::CreateWriter: dynamic_cast failed\n"); PutPlugin(plugin); return B_ERROR; } *writer = writerPlugin->NewWriter(); if (*writer == NULL) { printf("PluginManager::CreateWriter: NewWriter failed\n"); PutPlugin(plugin); return B_ERROR; } (*writer)->Setup(target); (*writer)->fMediaPlugin = plugin; TRACE("PluginManager::CreateWriter leave\n"); return B_OK; }
status_t BMediaFiles::RemoveItem(const char* type, const char* item) { CALLED(); server_remove_media_item_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); server_remove_media_item_reply reply; status_t status = QueryServer(SERVER_REMOVE_MEDIA_ITEM, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::RemoveItem: failed: %s\n", strerror(status)); return status; } return B_OK; }
status_t BMediaFiles::RemoveRefFor(const char* type, const char* item, const entry_ref &ref) { CALLED(); server_invalidate_item_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); server_invalidate_item_reply reply; status_t status = QueryServer(SERVER_INVALIDATE_MEDIA_ITEM, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::RemoveRefFor: failed: %s\n", strerror(status)); return status; } return B_OK; }
status_t BMediaFiles::SetAudioGainFor(const char* type, const char* item, float gain) { CALLED(); server_set_item_audio_gain_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); request.gain = gain; server_set_item_audio_gain_reply reply; status_t status = QueryServer(SERVER_SET_ITEM_AUDIO_GAIN, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::SetAudioGainFor: failed: %s\n", strerror(status)); return status; } return B_OK; }
status_t BMediaFiles::SetRefFor(const char* type, const char* item, const entry_ref& ref) { CALLED(); server_set_ref_for_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); request.ref = ref; server_set_ref_for_reply reply; status_t status = QueryServer(SERVER_SET_REF_FOR, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::SetRefFor: failed: %s\n", strerror(status)); return status; } return B_OK; }
void Network_Manager::ConnectToServer(char const* host, int port) { logWrite("Connecting to server %s:%d",host,port); Network_Connection* Connection = NewConnection(); Connection->socketHandle = -1; if (!Connection->Open(host, port)) { #ifdef WIN32 logWrite("Error while connecting to game server! (Code: %d)",GetLastError()); #else logWrite("Error while connecting to game server! (Code: %d)",errno); #endif return; } Game.IsHostingGame = false; IsServer = false; IsConnected = true; QueryServer(0); //Check protocol version //while (true) { //Frame(); //} }
status_t BMediaFiles::GetRefFor(const char* type, const char* item, entry_ref* _ref) { CALLED(); if (type == NULL || item == NULL || _ref == NULL) return B_BAD_VALUE; server_get_ref_for_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); server_get_ref_for_reply reply; status_t status = QueryServer(SERVER_GET_REF_FOR, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status)); return status; } *_ref = reply.ref; return B_OK; }
status_t BMediaFiles::GetAudioGainFor(const char* type, const char* item, float* _gain) { CALLED(); if (type == NULL || item == NULL || _gain == NULL) return B_BAD_VALUE; server_get_item_audio_gain_request request; strncpy(request.type, type, B_MEDIA_NAME_LENGTH); strncpy(request.item, item, B_MEDIA_NAME_LENGTH); server_get_item_audio_gain_reply reply; status_t status = QueryServer(SERVER_GET_ITEM_AUDIO_GAIN, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("BMediaFiles::GetRefFor: failed: %s\n", strerror(status)); return status; } *_gain = reply.gain; return B_OK; }
static DecoderPlugin * GetDecoderPlugin(const media_format * format) { server_get_decoder_for_format_request request; server_get_decoder_for_format_reply reply; request.format = *format; status_t result = QueryServer(SERVER_GET_DECODER_FOR_FORMAT, &request, sizeof(request), &reply, sizeof(reply)); if (result != B_OK) { printf("BMediaDecoder::SetTo: can't get decoder for format\n"); return NULL; } MediaPlugin * media_plugin = _plugin_manager.GetPlugin(reply.ref); if (!media_plugin) { printf("BMediaDecoder::SetTo: GetPlugin failed\n"); return NULL; } DecoderPlugin * plugin = dynamic_cast<DecoderPlugin *>(media_plugin); if (!plugin) { printf("BMediaDecoder::SetTo: dynamic_cast failed\n"); return NULL; } return plugin; }
//! For use by media_addon_server only media_addon_id DormantNodeManager::RegisterAddOn(const char* path) { TRACE("DormantNodeManager::RegisterAddon, path %s\n",path); entry_ref ref; status_t status = get_ref_for_path(path, &ref); if (status != B_OK) { ERROR("DormantNodeManager::RegisterAddon failed, couldn't get ref " "for path %s: %s\n", path, strerror(status)); return 0; } server_register_add_on_request request; request.ref = ref; server_register_add_on_reply reply; status = QueryServer(SERVER_REGISTER_ADD_ON, &request, sizeof(request), &reply, sizeof(reply)); if (status != B_OK) { ERROR("DormantNodeManager::RegisterAddon failed, couldn't talk to " "media server\n"); return 0; } if (status < B_OK) { ERROR("DormantNodeManager::RegisterAddon failed, couldn't talk to " "media server: %s\n", strerror(status)); return 0; } TRACE("DormantNodeManager::RegisterAddon finished with id %ld\n", reply.add_on_id); return reply.add_on_id; }
void pawsPetitionGMWindow::HandleMessage ( MsgEntry* me ) { //printf("Incomming Petition GM Petition Message\n"); // Get the petition message data from the server psPetitionMessage message(me); if (!message.isGM) { //printf("Bailing out because of message.isGM"); return; } if (message.msgType == PETITION_DIRTY && psengine->GetCelClient()->GetMainPlayer()->GetType() > 20) { if (hasPetInterest) { //printf("Looking for pet interest and bailing out\n"); QueryServer(); } return; } // if the server gave us a list of petitions, then use it // if (message.petitions.GetSize() > 0) petitionMessage = message; // Check if server reported errors on the query if (!message.success) { printf("Message was not a success\n"); psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); QueryServer(); //request the server a new petition list return; } // Check no petitions: if (message.petitions.GetSize() == 0) { //printf("No petitions in list\n"); petCount = 0; petitionList->Clear(); petitionList->NewRow(0); SetText(0, 1, PawsManager::GetSingleton().Translate("No Petitions")); return; } // Check its type (list, confirm, or assign): if (message.msgType == PETITION_CANCEL || message.msgType == PETITION_CLOSE) { // Check if server reported errors on the query if (!message.success) { printf("!message.succss\n"); psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); return; } // Change the status of the position we wanted to cancel: if (currentRow < 0) { // This should NEVER happen (it means the server gave a bogus message) Error1("PetitionGMWindow reports invalid currentRow!"); printf("Invalid currentRow\n"); return; } // Remove the item and refresh the list: // petitionMessage.petitions.DeleteIndex(currentRow); AddPetitions(petitionMessage.petitions); petitionList->Select(petitionList->GetRow(currentRow)); csString report; csString translation1 = PawsManager::GetSingleton().Translate("The selected petition was %s"); csString translation2 = PawsManager::GetSingleton().Translate(message.msgType == PETITION_CANCEL ? "cancelled.":"closed."); report.Format(translation1.GetData(), translation2.GetData()); psSystemMessage confirm(0,MSG_INFO,report.GetData()); msgqueue->Publish(confirm.msg); return; } if (message.msgType == PETITION_ASSIGN) { // Check if server reported errors on the query if (!message.success) { printf("Assign fail\n"); psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); return; } // Change the status of the position we wanted to assign: if (currentRow < 0) { printf("Bad row\n"); // This should NEVER happen (it means the server gave a bogus message) Error1("PetitionGMWindow reports invalid currentRow!"); return; } // Change the status of the item in the list box: // petitionMessage.petitions.Get(currentRow).status = "In Progress"; AddPetitions(petitionMessage.petitions); psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("You have been assigned to the selected petition.")); msgqueue->Publish(confirm.msg); return; } if (message.msgType == PETITION_DEASSIGN) { // Check if server reported errors on the query if (!message.success) { printf("dessign fail\n"); psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); return; } // Change the status of the position we wanted to assign: if (currentRow < 0) { printf("Bad row\n"); // This should NEVER happen (it means the server gave a bogus message) Error1("PetitionGMWindow reports invalid currentRow!"); return; } // Change the status of the item in the list box: AddPetitions(petitionMessage.petitions); psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("You have been deassigned from the selected petition.")); msgqueue->Publish(confirm.msg); return; } if (message.msgType == PETITION_ESCALATE) { //printf("Escalate\n"); // Check if server reported errors on the query if (!message.success) { psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); return; } // Change the status of the position we wanted to assign: if (currentRow < 0) { // This should NEVER happen (it means the server gave a bogus message) Error1("PetitionGMWindow reports invalid currentRow!"); return; } // Change the status of the item in the list box: // petitionMessage.petitions.Get(currentRow).escalation += 1; // petitionMessage.petitions.Get(currentRow).status = "Open"; AddPetitions(petitionMessage.petitions); psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition has been escalated.")); msgqueue->Publish(confirm.msg); return; } if (message.msgType == PETITION_DESCALATE) { //printf("Descalate\n"); // Check if server reported errors on the query if (!message.success) { psSystemMessage error(0,MSG_INFO,message.error); msgqueue->Publish(error.msg); return; } // Change the status of the position we wanted to assign: if (currentRow < 0) { // This should NEVER happen (it means the server gave a bogus message) Error1("PetitionGMWindow reports invalid currentRow!"); return; } // Change the status of the item in the list box: AddPetitions(petitionMessage.petitions); psSystemMessage confirm(0,MSG_INFO,PawsManager::GetSingleton().Translate("The selected petition has been descalated.")); msgqueue->Publish(confirm.msg); return; } // Update the listbox: int tempCount = petCount; AddPetitions(message.petitions); petitionList->SortRows(); ///sort the column specified in xml //alert GM that there are petitions waiting if (tempCount == -1) { csString message = PawsManager::GetSingleton().Translate("There are "); message += petCount; message += PawsManager::GetSingleton().Translate(" unanswered petitions."); //make a nice message psSystemMessage alert(0,MSG_INFO,message); //and send it msgqueue->Publish(alert.msg); } else if (petCount > tempCount) { psPetitionInfo info = message.petitions.Get(petCount-1); //get the last petition (supposed to be the new one) csString message = PawsManager::GetSingleton().Translate("New petition from ") + info.player.GetDataSafe(); //make a nice message psSystemMessage alert(0,MSG_INFO,message); //and send it msgqueue->Publish(alert.msg); } }
status_t PluginManager::CreateReader(Reader** reader, int32* streamCount, media_file_format* mff, BDataIO* source) { TRACE("PluginManager::CreateReader enter\n"); BPositionIO *seekable_source = dynamic_cast<BPositionIO *>(source); if (seekable_source == 0) { printf("PluginManager::CreateReader: non-seekable sources not " "supported yet\n"); return B_ERROR; } // get list of available readers from the server server_get_readers_request request; server_get_readers_reply reply; status_t ret = QueryServer(SERVER_GET_READERS, &request, sizeof(request), &reply, sizeof(reply)); if (ret != B_OK) { printf("PluginManager::CreateReader: can't get list of readers: %s\n", strerror(ret)); return ret; } // try each reader by calling it's Sniff function... for (int32 i = 0; i < reply.count; i++) { entry_ref ref = reply.ref[i]; MediaPlugin* plugin = GetPlugin(ref); if (plugin == NULL) { printf("PluginManager::CreateReader: GetPlugin failed\n"); return B_ERROR; } ReaderPlugin* readerPlugin = dynamic_cast<ReaderPlugin*>(plugin); if (readerPlugin == NULL) { printf("PluginManager::CreateReader: dynamic_cast failed\n"); PutPlugin(plugin); return B_ERROR; } *reader = readerPlugin->NewReader(); if (*reader == NULL) { printf("PluginManager::CreateReader: NewReader failed\n"); PutPlugin(plugin); return B_ERROR; } seekable_source->Seek(0, SEEK_SET); (*reader)->Setup(seekable_source); (*reader)->fMediaPlugin = plugin; if ((*reader)->Sniff(streamCount) == B_OK) { TRACE("PluginManager::CreateReader: Sniff success " "(%ld stream(s))\n", *streamCount); (*reader)->GetFileFormatInfo(mff); return B_OK; } DestroyReader(*reader); } TRACE("PluginManager::CreateReader leave\n"); return B_MEDIA_NO_HANDLER; }