void CBTHidConnection::Disconnect() //Virtual Cable Unplug. (this is not Bluetooth disconnect) { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::Disconnect (Virtual Cable Unplug)")); if (iConnectionState == EConnected) { //First Send VCUnplug iCommandBuffer.Zero(); iCommandBuffer.Append(EHIDControlVCUnplug); TRequestStatus status; iControlSocket->Write(iCommandBuffer, status); User::WaitForRequest(status); //Then wait for a reply from Su-8W on L2CAP channel(s). If not waited, Su-8W will go mad. User::After(500000); //0.5 sec //but we never handle that acknowledgement (because it is not required by BT HID //specification, but Su-8W needs to send something.) iControlSocketWriter->Cancel(); iControlSocketReader->Cancel(); iInterruptSocketReader->Cancel(); iInterruptSocketWriter->Cancel(); } }
void CBTHidConnection::DropConnection() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::DropConnection")); // Close the Bluetooth Channels. CloseChannels(); // Update the connection state. ChangeState(ELinkLost); // If a command is outstanding if (iCommandIssued) { // Generate an error to the parent. iObserver.HandleCommandAck(iConnID, KErrNotReady); // Reset the command flag. iCommandIssued = EFalse; // Reset this, so we don't leave it in a bad state. if (iCommandSegmenter) { iCommandSegmenter->Reset(); } } }
void CBTHidConnection::ConstructL() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::ConstructL")); //ChangeState(ENotConnected); // A new hid device information object. iDevice = CBTHidDevice::NewL(); // Socket readers and writer objects to perform asynchronous requests iControlSocketReader = CSocketReader::NewL(EControlSocketID, *this, KL2CAPDefaultMTU); iControlSocketWriter = CSocketWriter::NewL(EControlSocketID, *this); iInterruptSocketReader = CSocketReader::NewL(EInterruptSocketID, *this, KL2CAPDefaultMTU); iInterruptSocketWriter = CSocketWriter::NewL(EInterruptSocketID, *this); // Socket initiator to perform socket connections iSocketInitiator = CSocketInitiator::NewL(iSocketServ, *this); // Create a timeout timer iInactivityTimer = CTimeOutTimer::NewL(EPriorityHigh, *this); }
CELL * bi_index(CELL *sp) { size_t idx; size_t len; const char *p; TRACE_FUNC("bi_index", sp); sp--; if (TEST2(sp) != TWO_STRINGS) cast2_to_s(sp); if ((len = string(sp + 1)->len)) { idx = (size_t) ((p = str_str(string(sp)->str, string(sp)->len, string(sp + 1)->str, len)) ? p - string(sp)->str + 1 : 0); } else { /* index of the empty string */ idx = 1; } free_STRING(string(sp)); free_STRING(string(sp + 1)); sp->type = C_DOUBLE; sp->dval = (double) idx; return_CELL("bi_index", sp); }
// from MSocketObserver TBool CBTHidConnection::HandleDataReceived(TUint aSocketID, const TDesC8& aBuffer) { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::HandledataReceived")); TBool result = ETrue; // Cancel the inactivity timer. iInactivityTimer->Cancel(); switch (aSocketID) { case EControlSocketID: result = ProcessControlData(aBuffer); break; case EInterruptSocketID: result = ProcessInterruptData(aBuffer); break; default: // Shouldn't have any other socket id User::Panic(KPanicBTConnection, ESocketsUnknownID); break; } // If the device will reconnect to us we are ok to drop the link // after a period of inactivity. if ((result) && (iDevice->iReconnectInit)) { iInactivityTimer->After(KInactivityTimeout); } return result; }
void CImageRotator::RunL() { if(iStatus == KErrNone){ if(RotationNum == 1) { RotationNum = 2; iPicture->iBitmap = iBitmap; if(iMask != NULL) { iBmpRotator->Rotate(&iStatus, *iMask, iAngle); #ifdef USE_TRACE TRACE_FUNC(); #endif SetActive(); } else { iPicture->RotationComplete(); DoCancel(); } } else if(RotationNum == 2) { RotationNum = 3; iPicture->iMask = iMask; iPicture->RotationComplete(); DoCancel(); } } }
CELL * bi_printf(CELL *sp) { register int k; register CELL *p; FILE *fp; TRACE_FUNC("bi_printf", sp); k = sp->type; if (k < 0) { /* k has redirection */ if ((--sp)->type < C_STRING) cast1_to_s(sp); fp = (FILE *) file_find(string(sp), k); free_STRING(string(sp)); k = (--sp)->type; /* k is now number of args including format */ } else fp = stdout; sp -= k; /* sp points at the format string */ k--; if (sp->type < C_STRING) cast1_to_s(sp); do_printf(fp, string(sp)->str, (unsigned) k, sp + 1); free_STRING(string(sp)); /* cleanup arguments on eval stack */ for (p = sp + 1; k; k--, p++) cell_destroy(p); return --sp; }
void CBTHidConnection::ConnectL() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::ConnectL")); // If we aren't in the correct stiDeviceate for an initial connection Panic. __ASSERT_DEBUG(iConnectionState == ENotConnected || iConnectionState == EConnecting, User::Panic(KPanicBTConnection, ESocketsBadState)); // Create the two sockets. delete iControlSocket; iControlSocket = 0; iControlSocket = new (ELeave) RSocket; // If we leave after this iControlSocket will not be NULL. // This is ok since any place where it can be set will delete it first // or it will be finally deleted in the destructor delete iInterruptSocket; iInterruptSocket = 0; iInterruptSocket = new (ELeave) RSocket; // If we leave after this iControlSocket & iInterruptSocket will not // be NULL. // This is ok since any place where they can be set will delete first // or they will be finally deleted in the destructor // Ask the socket initiator to connect these sockets, // giving it the bluetooth address of the device and a security flag. iSocketInitiator->ConnectSocketsL(iDevice->iAddress, iDevice->iUseSecurity, iControlSocket, iInterruptSocket); ChangeState(EFirstConnection); }
void CBTHidConnection::ConnectionLost() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::ConnectionLost")); CloseChannels(); // First go into link loss state ChangeState(ELinkLost); // If a command is outstanding if (iCommandIssued) { TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, command outstanding")); // Generate an error to the parent. iObserver.HandleCommandAck(iConnID, KErrNotReady); // Reset the command flag. iCommandIssued = EFalse; // Reset this, so we don't leave it in a bad state. if (iCommandSegmenter) { iCommandSegmenter->Reset(); } } // Check if the device will reconnect to us. if (iDevice->iReconnectInit) { TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, device inits reconnect")); // Inform the parent of the link loss and the fact we are not // reconnecting iObserver.LinkLost(iConnID); } else { TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, host inits reconnect")); // Device won't reconnect, check if we are able to. if (iDevice->iNormallyConnectable) { TRACE_INFO(_L("[BTHID]\tCBTHidConnection::ConnectionLost, device is normally connectable")); // Attempt to initiate reconnection to the device. TRAPD(res, iSocketInitiator->ConnectSocketsL(iDevice->iAddress, iDevice->iUseSecurity, iControlSocket, iInterruptSocket);) if (res == KErrNone) { // Reconnection is in progress, so record this and inform // the parent. ChangeState(EHostReconnecting); iObserver.LinkLost(iConnID); } else { // Inform the parent of the link loss and the fact we are not // reconnecting iObserver.LinkLost(iConnID); } }
static int adxl345_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct adxl345_data *adxl345; int err; TRACE_FUNC(); /* setup private data */ adxl345 = kzalloc(sizeof(struct adxl345_data), GFP_KERNEL); if (!adxl345) { err = -ENOMEM; goto error_0; } mutex_init(&adxl345->enable_mutex); mutex_init(&adxl345->data_mutex); /* setup i2c client */ if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { err = -ENODEV; goto error_1; } i2c_set_clientdata(client, adxl345); adxl345->client = client; /* detect and init hardware */ if ((err = adxl345_detect(client, NULL))) { goto error_1; } dev_info(&client->dev, "%s found\n", id->name); adxl345_hw_init(adxl345); adxl345_set_delay(&client->dev, ADXL345_DEFAULT_DELAY); adxl345_set_position(&client->dev, CONFIG_INPUT_ADXL345_POSITION); /* setup driver interfaces */ INIT_DELAYED_WORK(&adxl345->work, adxl345_work_func); err = adxl345_input_init(adxl345); if (err < 0) { goto error_1; } err = sysfs_create_group(&adxl345->input->dev.kobj, &adxl345_attribute_group); if (err < 0) { goto error_2; } return 0; error_2: adxl345_input_fini(adxl345); error_1: kfree(adxl345); error_0: return err; }
CVicinityView::~CVicinityView() { TRACE_FUNC(); if(iContainer) { AppUi()->RemoveFromViewStack(* this, iContainer); } delete iContainer; }
void CImageRotator::RotateBitmap() { RotationNum =1; iBmpRotator->Rotate(&iStatus, *iBitmap, iAngle); #ifdef USE_TRACE TRACE_FUNC(); #endif SetActive(); }
CELL * bi_int(CELL *sp) { TRACE_FUNC("bi_int", sp); if (sp->type != C_DOUBLE) cast1_to_d(sp); sp->dval = sp->dval >= 0.0 ? floor(sp->dval) : ceil(sp->dval); return_CELL("bi_int", sp); }
///Calculates the probability for a certain Newick ///with a certain theta. This is the main (helper) ///function. double ribi::ManyDigitNewick::CalculateProbability( const std::string& newick_str, const double theta) { TRACE_FUNC(); ribi::ManyDigitNewick::SetTheta(theta); const NewickVector n(newick_str); const ManyDigitNewickIndexer i(n,theta); return i.GetProbability(); }
CELL * bi_srand(CELL *sp) { #ifdef USE_SYSTEM_SRAND static long seed = 1; static CELL cseed = { C_DOUBLE, 0, 0, 1.0 }; #endif CELL c; TRACE_FUNC("bi_srand", sp); if (sp->type == C_NOINIT) /* seed off clock */ { cellcpy(sp, &cseed); cell_destroy(&cseed); cseed.type = C_DOUBLE; cseed.dval = initial_seed(); } else { /* user seed */ sp--; /* swap cseed and *sp ; don't need to adjust ref_cnts */ c = *sp; *sp = cseed; cseed = c; } #ifdef USE_SYSTEM_SRAND seed = d_to_i(cseed.dval); mawk_srand((unsigned) seed); #else /* The old seed is now in *sp ; move the value in cseed to seed in range [1,M) */ cellcpy(&c, &cseed); if (c.type == C_NOINIT) cast1_to_d(&c); seed = ((c.type == C_DOUBLE) ? (long) (d_to_i(c.dval) & M) % M + 1 : (long) hash(string(&c)->str) % M + 1); if (seed == M) seed = M - 1; cell_destroy(&c); /* crank it once so close seeds don't give a close first result */ crank(seed); #endif return_CELL("bi_srand", sp); }
void CBTHidConnection::ReconnectL() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::ReconnectL")); // If we aren't in the correct state for an reconnection Panic. __ASSERT_DEBUG(iConnectionState == ENotConnected, User::Panic(KPanicBTConnection, ESocketsBadState)); // Expect the device to reconnect for now ChangeState(ELinkLost); }
void ribi::Chess::QtChessBoardWidget::keyPressEvent(QKeyEvent * e) { TRACE_FUNC(); switch (e->key()) { case Qt::Key_Up: this->m_widget->GetSelector()->MoveUp(); break; case Qt::Key_Right: this->m_widget->GetSelector()->MoveRight(); break; case Qt::Key_Down: this->m_widget->GetSelector()->MoveDown(); break; case Qt::Key_Left: this->m_widget->GetSelector()->MoveLeft(); break; case Qt::Key_Space: this->m_widget->GetSelector()->DoSelect(); break; } }
ribi::gtst::Resources::Resources() { TRACE_FUNC(); //Create the default parameters file { const std::string filename = "wt.css"; if (!fileio::FileIo().IsRegularFile(filename)) { SaveStylesheet(); } assert(fileio::FileIo().IsRegularFile(filename)); } const std::vector<std::string> image_names = { //GetImageFilenameBackground(), GetImageFilenameCycle(), GetImageFilenameExperiment(), GetImageFilenameGroups(), GetImageFilenameParticipantDialogAssignPayoff(), GetImageFilenameParticipantDialogChat(), GetImageFilenameParticipantDialogChooseAction(), GetImageFilenameParticipantDialogFinished(), GetImageFilenameParticipantDialogGroupAssign(), GetImageFilenameParticipantDialogGroupReAssign(), GetImageFilenameParticipantDialogLoggedIn(), GetImageFilenameParticipantDialogNotLoggedIn(), GetImageFilenameParticipantDialogViewResultsGroup(), GetImageFilenameParticipantDialogViewResultsVoting(), GetImageFilenameParticipantDialogVoting(), GetImageFilenamePeriod() }; std::for_each(image_names.begin(),image_names.end(), [](const std::string& filename) { if (!fileio::FileIo().IsRegularFile(filename)) { QFile f( (std::string(":/images/") + filename).c_str() ); f.copy(filename.c_str()); if (!fileio::FileIo().IsRegularFile(filename)) { const std::string s = "File not found: " + filename; std::cerr << s << '\n'; std::clog << s << '\n'; std::cout << s << '\n'; } } assert(fileio::FileIo().IsRegularFile(filename)); } ); }
void CBTHidConnection::OfferInterruptSocket(const TBTDevAddr& aAddress, RSocket*& aSocket) { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::OfferInterruptSocket")); if (aAddress == iDevice->iAddress) { __ASSERT_DEBUG((iConnectionState == EHIDReconnecting) ||(iConnectionState == EHIDInitConnecting) , User::Panic(KPanicBTConnection, ESocketsBadState)); // Take ownership of this socket delete iInterruptSocket; iInterruptSocket = aSocket; aSocket = 0; TRAPD(error, PrepareSocketsL()); if (KErrNone == error) { // Mark that we are now reconnected. TBTConnectionState prevState = iConnectionState; ChangeState(EConnected); if (prevState == EHIDInitConnecting) { // If this was an remote HID initial connection, start the SDP Search. iObserver.StartSDPSearch(iConnID); } else { // Inform the observer that the connection has been restored. iObserver.LinkRestored(iConnID); } } else { // Close the sockets as they can't be used CloseChannels(); if (iConnectionState == EHIDInitConnecting) { ChangeState(ENotConnected); // If this was an remote HID initial connection inform the observer iObserver.FirstTimeConnectionCompleteFromRemote(iConnID, error); } else { ChangeState(ELinkLost); } } } }
ribi::QtNsanaBrosKeysWidget::QtNsanaBrosKeysWidget( const NsanaBrosKeys * const keys, QWidget *parent) : QWidget(parent), m_keys(keys) { TRACE_FUNC(); m_keys->m_signal_keyschanged.connect( boost::bind( &ribi::QtNsanaBrosKeysWidget::OnKeysChanged, this)); }
/* * Like gawk... */ CELL * bi_systime(CELL *sp) { time_t result; time(&result); TRACE_FUNC("bi_systime", sp); sp++; sp->type = C_DOUBLE; sp->dval = (double) result; return_CELL("bi_systime", sp); }
void CImageConverter::RunL() { if(iStatus == KErrNone){ iPicture.DecodeComplete(iBitmap, iMask); delete iDecoder; iDecoder = NULL; } else if(iStatus == KErrUnderflow){ iDecoder->ContinueConvert(&iStatus); #ifdef USE_TRACE TRACE_FUNC(); #endif SetActive(); } }
int send_play_reply(RTSP_buffer * rtsp, char *object, RTSP_session * rtsp_session) { char r[1024]; char temp[30]; RTP_session *p = rtsp_session->rtp_session; TRACE_FUNC(); /* build a reply message */ sprintf(r, "%s %d %s" RTSP_EL "CSeq: %d" RTSP_EL "Server: %s/%s" RTSP_EL, RTSP_VER, 200, get_stat(200), rtsp->rtsp_cseq, PACKAGE, VERSION); add_time_stamp(r, 0); strcat(r, "Session: "); sprintf(temp, "%d", rtsp_session->session_id); strcat(r, temp); strcat(r, RTSP_EL); // strcat(r, "RTP-info: url="); strcat(r, "RTP-info: "); // strcat(r, object); // strcat(r, ";"); do { strcat(r, "url="); // strcat(r, object); // TODO: we MUST be sure to send the correct url sprintf(r + strlen(r), "rtsp://%s/%s/%s!%s", prefs_get_hostname(), p->sd_filename, p->sd_filename, p->current_media->filename); strcat(r, ";"); sprintf(r + strlen(r), "seq=%u;rtptime=%u", p->start_seq, p->start_rtptime); if (p->next != NULL) { strcat(r, ","); } else { // strcat(r, "\r\n\r\n"); strcat(r, RTSP_EL); } p = p->next; } while (p != NULL); // end of message strcat(r, RTSP_EL); bwrite(r, (unsigned short) strlen(r), rtsp); // INFOLOGG("200 - %s ", object); return ERR_NOERROR; }
// from MSocketObserver void CBTHidConnection::HandleWriteComplete(TUint aSocketID) { //to handle DATA Output in interrupt channel (Host to Device DATA) // Check the ID of the socket TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::HandleWriteComplete")); if (aSocketID == EControlSocketID || aSocketID == EInterruptSocketID) { // Send any additional packets on the control channel if (iCommandSegmenter) { const HBufC8* data = iCommandSegmenter->NextPacket(); if (data) { if (aSocketID == EControlSocketID) { TRAPD(err, iControlSocketWriter->IssueWriteL(*data)); if (KErrNone != err) { // Reset this, so we don't leave it in a bad state. iCommandSegmenter->Reset(); iCommandIssued = EFalse; iObserver.HandleCommandAck(iConnID, err); } } else //aSocketID == EInterruptSocketID { TRAPD(err, iInterruptSocketWriter->IssueWriteL(*data)); if (KErrNone != err) { // Reset this, so we don't leave it in a bad state. iCommandSegmenter->Reset(); iCommandIssued = EFalse; iObserver.HandleCommandAck(iConnID, err); } } } if (!data && aSocketID == EInterruptSocketID && iCommandIssued) { //We don't expect response from HID Device, However we'll notify GenericHID //that async write operation has been finished. iObserver.HandleCommandAck(iConnID, KErrNone); //Socket write complete! iCommandIssued = EFalse; } } } }
TEST(Log, Trace) { StdoutLogMsgHandler handler; LogControl logControl; logControl.registerMsgHandler(&handler); TestUtilLogControlSwap swap(&logControl); TRACE("trace message"); TRACE_FUNC(); TRACE_FUNC2("trace func message"); TRACE_FUNC_IN(); TRACE_FUNC_OUT(); swap.restore(); }
CELL * bi_close(CELL *sp) { int x; TRACE_FUNC("bi_close", sp); if (sp->type < C_STRING) cast1_to_s(sp); x = file_close((STRING *) sp->ptr); free_STRING(string(sp)); sp->type = C_DOUBLE; sp->dval = (double) x; return_CELL("bi_close", sp); }
void CBTHidConnection::StartMonitoringChannelsL() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::StartMonitoringChannelsL")); __ASSERT_DEBUG(iConnectionState == EConnected, User::Panic(KPanicBTConnection, ESocketsBadState)); iControlSocketReader->StartReadingL(iControlSocket, iControlInMTU); iInterruptSocketReader->StartReadingL(iInterruptSocket, iInterruptInMTU); // If the device will reconnect to us we are ok to drop the link // after a period of inactivity. if (iDevice->iReconnectInit) { iInactivityTimer->Cancel(); iInactivityTimer->After(KInactivityTimeout); } }
/* mktime(datespec) Turns datespec into a time stamp of the same form as returned by systime(). The datespec is a string of the form YYYY MM DD HH MM SS [DST]. */ CELL * bi_mktime(CELL *sp) { time_t result; struct tm my_tm; STRING *sval = string(sp); int error = 0; TRACE_FUNC("bi_mktime", sp); memset(&my_tm, 0, sizeof(my_tm)); switch (sscanf(sval->str, "%d %d %d %d %d %d %d", &my_tm.tm_year, &my_tm.tm_mon, &my_tm.tm_mday, &my_tm.tm_hour, &my_tm.tm_min, &my_tm.tm_sec, &my_tm.tm_isdst)) { case 7: break; case 6: my_tm.tm_isdst = -1; /* ask mktime to get timezone */ break; default: error = 1; /* not enough data */ break; } if (error) { result = -1; } else { my_tm.tm_year -= 1900; my_tm.tm_mon -= 1; result = mktime(&my_tm); } TRACE(("...bi_mktime(%s) ->%s", sval->str, ctime(&result))); cell_destroy(sp); sp->type = C_DOUBLE; sp->dval = (double) result; return_CELL("bi_mktime", sp); }
void CBTHidConnection::PrepareSocketsL() { TRACE_FUNC (_L("[BTHID]\tCBTHidConnection::PrepareSockets")); // Retrieve the MTU values from the sockets User::LeaveIfError(iControlSocket->GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, iControlOutMTU)); User::LeaveIfError(iControlSocket->GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, iControlInMTU)); User::LeaveIfError(iInterruptSocket->GetOpt(KL2CAPInboundMTU, KSolBtL2CAP, iInterruptInMTU)); User::LeaveIfError(iInterruptSocket->GetOpt(KL2CAPGetOutboundMTU, KSolBtL2CAP, iInterruptOutMTU)); // Initialise the control socket writer with the new socket. iControlSocketWriter->Initialise(iControlSocket); // Initialise the interrupt socket writer with the new socket. iInterruptSocketWriter->Initialise(iInterruptSocket); }
CELL * bi_rand(CELL *sp) { TRACE_FUNC("bi_rand", sp); #ifdef USE_SYSTEM_SRAND { long value = (long) mawk_rand(); sp++; sp->type = C_DOUBLE; sp->dval = ((double) value) / RAND_MAX; } #else crank(seed); sp++; sp->type = C_DOUBLE; sp->dval = (double) seed / (double) M; #endif return_CELL("bi_rand", sp); }