62 #ifdef _DEBUG |
62 #ifdef _DEBUG |
63 SelfTestL(); |
63 SelfTestL(); |
64 #endif |
64 #endif |
65 |
65 |
66 #ifndef STIF |
66 #ifndef STIF |
67 User::LeaveIfError(RProperty::Define(KPSUidUsbWatcher, |
67 LEAVEIFERROR(RProperty::Define(KPSUidUsbWatcher, |
68 KUsbWatcherIsPeripheralConnected, RProperty::EInt, |
68 KUsbWatcherIsPeripheralConnected, RProperty::EInt, |
69 KAlwaysPassPolicy, KLocalServicesPolicy)); |
69 KAlwaysPassPolicy, KLocalServicesPolicy)); |
70 |
70 |
71 User::LeaveIfError(RProperty::Set(KPSUidUsbWatcher, |
71 LEAVEIFERROR(RProperty::Set(KPSUidUsbWatcher, |
72 KUsbWatcherIsPeripheralConnected, |
72 KUsbWatcherIsPeripheralConnected, |
73 KUsbWatcherPeripheralIsNotConnected)); |
73 KUsbWatcherPeripheralIsNotConnected)); |
74 #endif |
74 #endif |
75 |
75 |
76 iUsbServiceControl = CUsbServiceControl::NewL(*this, iUsb); |
76 iUsbServiceControl = CUsbServiceControl::NewL(*this, iUsb); |
77 |
77 |
78 User::LeaveIfError(iStates.Append(CUsbStateHostUndefined::NewL(*this))); |
78 LEAVEIFERROR(iStates.Append(CUsbStateHostUndefined::NewL(*this))); |
79 User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); |
79 LEAVEIFERROR(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); |
80 User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(*this))); |
80 LEAVEIFERROR(iStates.Append(CUsbStateHostAHost::NewL(*this))); |
81 User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); |
81 LEAVEIFERROR(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); |
82 |
82 |
83 User::LeaveIfError(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( |
83 LEAVEIFERROR(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( |
84 *this))); |
84 *this))); |
85 User::LeaveIfError(iStates.Append( |
85 LEAVEIFERROR(iStates.Append( |
86 CUsbStateHostDelayNotAttachedHandle::NewL(*this))); |
86 CUsbStateHostDelayNotAttachedHandle::NewL(*this))); |
87 User::LeaveIfError(iStates.Append( |
87 LEAVEIFERROR(iStates.Append( |
88 CUsbStateHostHandleDropping::NewL(*this))); |
88 CUsbStateHostHandleDropping::NewL(*this))); |
89 |
89 |
90 iIdPinObserver = CUsbIdPinObserver::NewL(); |
90 iIdPinObserver = CUsbIdPinObserver::NewL(); |
91 iVBusObserver = CUsbVBusObserver::NewL(); |
91 iVBusObserver = CUsbVBusObserver::NewL(); |
92 iOtgStateObserver = CUsbOtgStateObserver::NewL(); |
92 iOtgStateObserver = CUsbOtgStateObserver::NewL(); |
93 iBusActivityObserver = CUsbBusActivityObserver::NewL(); |
93 iBusActivityObserver = CUsbBusActivityObserver::NewL(); |
408 // |
408 // |
409 // --------------------------------------------------------------------------- |
409 // --------------------------------------------------------------------------- |
410 // |
410 // |
411 void CUsbOtgWatcher::AIdleL() |
411 void CUsbOtgWatcher::AIdleL() |
412 { |
412 { |
413 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
413 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
414 iHostState->AIdleL(); |
414 iHostState->AIdleL(); |
415 } |
415 } |
416 |
416 |
417 // --------------------------------------------------------------------------- |
417 // --------------------------------------------------------------------------- |
418 // |
418 // |
419 // --------------------------------------------------------------------------- |
419 // --------------------------------------------------------------------------- |
420 // |
420 // |
421 void CUsbOtgWatcher::AHostL() |
421 void CUsbOtgWatcher::AHostL() |
422 { |
422 { |
423 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
423 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
424 iHostState->AHostL(); |
424 iHostState->AHostL(); |
425 } |
425 } |
426 |
426 |
427 // --------------------------------------------------------------------------- |
427 // --------------------------------------------------------------------------- |
428 // |
428 // |
429 // --------------------------------------------------------------------------- |
429 // --------------------------------------------------------------------------- |
430 // |
430 // |
431 void CUsbOtgWatcher::APeripheralL() |
431 void CUsbOtgWatcher::APeripheralL() |
432 { |
432 { |
433 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
433 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
434 iHostState->APeripheralL(); |
434 iHostState->APeripheralL(); |
435 } |
435 } |
436 |
436 |
437 // --------------------------------------------------------------------------- |
437 // --------------------------------------------------------------------------- |
438 // |
438 // |
439 // --------------------------------------------------------------------------- |
439 // --------------------------------------------------------------------------- |
440 // |
440 // |
441 void CUsbOtgWatcher::AVBusErrorL() |
441 void CUsbOtgWatcher::AVBusErrorL() |
442 { |
442 { |
443 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
443 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
444 iHostState->AVBusErrorL(); |
444 iHostState->AVBusErrorL(); |
445 } |
445 } |
446 |
446 |
447 // --------------------------------------------------------------------------- |
447 // --------------------------------------------------------------------------- |
448 // |
448 // |
449 // --------------------------------------------------------------------------- |
449 // --------------------------------------------------------------------------- |
450 // |
450 // |
451 void CUsbOtgWatcher::BIdleL() |
451 void CUsbOtgWatcher::BIdleL() |
452 { |
452 { |
453 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
453 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
454 iHostState->BIdleL(); |
454 iHostState->BIdleL(); |
455 } |
455 } |
456 |
456 |
457 // --------------------------------------------------------------------------- |
457 // --------------------------------------------------------------------------- |
458 // |
458 // |
459 // --------------------------------------------------------------------------- |
459 // --------------------------------------------------------------------------- |
460 // |
460 // |
461 void CUsbOtgWatcher::BPeripheralL() |
461 void CUsbOtgWatcher::BPeripheralL() |
462 { |
462 { |
463 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
463 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
464 iHostState->BPeripheralL(); |
464 iHostState->BPeripheralL(); |
465 } |
465 } |
466 |
466 |
467 // --------------------------------------------------------------------------- |
467 // --------------------------------------------------------------------------- |
468 // |
468 // |
469 // --------------------------------------------------------------------------- |
469 // --------------------------------------------------------------------------- |
470 // |
470 // |
471 void CUsbOtgWatcher::BHostL() |
471 void CUsbOtgWatcher::BHostL() |
472 { |
472 { |
473 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
473 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
474 iHostState->BHostL(); |
474 iHostState->BHostL(); |
475 } |
475 } |
476 |
476 |
477 // --------------------------------------------------------------------------- |
477 // --------------------------------------------------------------------------- |
478 // |
478 // |
479 // --------------------------------------------------------------------------- |
479 // --------------------------------------------------------------------------- |
480 // |
480 // |
481 void CUsbOtgWatcher::OtgStateErrorL(TInt aError) |
481 void CUsbOtgWatcher::OtgStateErrorL(TInt aError) |
482 { |
482 { |
483 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
483 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
484 HandleHostProblemL(EUsbWatcherOtgStateError, EUsbStateHostHandleDropping); |
484 HandleHostProblemL(EUsbWatcherOtgStateError, EUsbStateHostHandleDropping); |
485 } |
485 } |
486 |
486 |
487 // From bus activity observer |
487 // From bus activity observer |
488 // --------------------------------------------------------------------------- |
488 // --------------------------------------------------------------------------- |
489 // |
489 // |
490 // --------------------------------------------------------------------------- |
490 // --------------------------------------------------------------------------- |
491 // |
491 // |
492 void CUsbOtgWatcher::BusIdleL() |
492 void CUsbOtgWatcher::BusIdleL() |
493 { |
493 { |
494 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
494 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
495 iHostState->BusIdleL(); |
495 iHostState->BusIdleL(); |
496 } |
496 } |
497 |
497 |
498 // --------------------------------------------------------------------------- |
498 // --------------------------------------------------------------------------- |
499 // |
499 // |
500 // --------------------------------------------------------------------------- |
500 // --------------------------------------------------------------------------- |
501 // |
501 // |
502 void CUsbOtgWatcher::BusActiveL() |
502 void CUsbOtgWatcher::BusActiveL() |
503 { |
503 { |
504 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
504 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
505 iHostState->BusActiveL(); |
505 iHostState->BusActiveL(); |
506 } |
506 } |
507 |
507 |
508 // --------------------------------------------------------------------------- |
508 // --------------------------------------------------------------------------- |
509 // |
509 // |
510 // --------------------------------------------------------------------------- |
510 // --------------------------------------------------------------------------- |
511 // |
511 // |
512 void CUsbOtgWatcher::BusActivityErrorL(TInt aError) |
512 void CUsbOtgWatcher::BusActivityErrorL(TInt aError) |
513 { |
513 { |
514 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
514 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
515 // no action, continue |
515 // no action, continue |
516 } |
516 } |
517 |
517 |
518 // From Host Event notification observer |
518 // From Host Event notification observer |
519 // --------------------------------------------------------------------------- |
519 // --------------------------------------------------------------------------- |
520 // |
520 // |
521 // --------------------------------------------------------------------------- |
521 // --------------------------------------------------------------------------- |
522 // |
522 // |
523 void CUsbOtgWatcher::DeviceAttachedL(TDeviceEventInformation aTdi) |
523 void CUsbOtgWatcher::DeviceAttachedL(TDeviceEventInformation aTdi) |
524 { |
524 { |
525 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
525 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
526 iHostState->DeviceAttachedL(aTdi); |
526 iHostState->DeviceAttachedL(aTdi); |
527 } |
527 } |
528 |
528 |
529 // --------------------------------------------------------------------------- |
529 // --------------------------------------------------------------------------- |
530 // |
530 // |
531 // --------------------------------------------------------------------------- |
531 // --------------------------------------------------------------------------- |
532 // |
532 // |
533 void CUsbOtgWatcher::DeviceDetachedL(TDeviceEventInformation aTdi) |
533 void CUsbOtgWatcher::DeviceDetachedL(TDeviceEventInformation aTdi) |
534 { |
534 { |
535 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
535 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
536 iHostState->DeviceDetachedL(aTdi); |
536 iHostState->DeviceDetachedL(aTdi); |
537 } |
537 } |
538 |
538 |
539 // --------------------------------------------------------------------------- |
539 // --------------------------------------------------------------------------- |
540 // |
540 // |
541 // --------------------------------------------------------------------------- |
541 // --------------------------------------------------------------------------- |
542 // |
542 // |
543 void CUsbOtgWatcher::DriverLoadSuccessL(TDeviceEventInformation aTdi) |
543 void CUsbOtgWatcher::DriverLoadSuccessL(TDeviceEventInformation aTdi) |
544 { |
544 { |
545 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
545 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
546 iHostState->DriverLoadSuccessL(aTdi); |
546 iHostState->DriverLoadSuccessL(aTdi); |
547 } |
547 } |
548 |
548 |
549 // --------------------------------------------------------------------------- |
549 // --------------------------------------------------------------------------- |
550 // |
550 // |
551 // --------------------------------------------------------------------------- |
551 // --------------------------------------------------------------------------- |
552 // |
552 // |
553 void CUsbOtgWatcher::DriverLoadPartialSuccessL(TDeviceEventInformation aTdi) |
553 void CUsbOtgWatcher::DriverLoadPartialSuccessL(TDeviceEventInformation aTdi) |
554 { |
554 { |
555 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
555 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
556 iHostState->DriverLoadPartialSuccessL(aTdi); |
556 iHostState->DriverLoadPartialSuccessL(aTdi); |
557 } |
557 } |
558 |
558 |
559 // --------------------------------------------------------------------------- |
559 // --------------------------------------------------------------------------- |
560 // |
560 // |
561 // --------------------------------------------------------------------------- |
561 // --------------------------------------------------------------------------- |
562 // |
562 // |
563 void CUsbOtgWatcher::DriverLoadFailureL(TDeviceEventInformation aTdi) |
563 void CUsbOtgWatcher::DriverLoadFailureL(TDeviceEventInformation aTdi) |
564 { |
564 { |
565 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
565 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
566 iHostState->DriverLoadFailureL(aTdi); |
566 iHostState->DriverLoadFailureL(aTdi); |
567 } |
567 } |
568 |
568 |
569 // --------------------------------------------------------------------------- |
569 // --------------------------------------------------------------------------- |
570 // |
570 // |
571 // --------------------------------------------------------------------------- |
571 // --------------------------------------------------------------------------- |
572 // |
572 // |
573 void CUsbOtgWatcher::HostEventNotificationErrorL(TInt aError) |
573 void CUsbOtgWatcher::HostEventNotificationErrorL(TInt aError) |
574 { |
574 { |
575 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
575 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
576 HandleHostProblemL(EUsbWatcherHostEventNotificationError, |
576 HandleHostProblemL(EUsbWatcherHostEventNotificationError, |
577 EUsbStateHostHandleDropping); |
577 EUsbStateHostHandleDropping); |
578 } |
578 } |
579 |
579 |
580 // From message notification observer |
580 // From message notification observer |
582 // |
582 // |
583 // --------------------------------------------------------------------------- |
583 // --------------------------------------------------------------------------- |
584 // |
584 // |
585 void CUsbOtgWatcher::MessageNotificationReceivedL(TInt aMessage) |
585 void CUsbOtgWatcher::MessageNotificationReceivedL(TInt aMessage) |
586 { |
586 { |
587 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
587 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
588 iHostState->MessageNotificationReceivedL(aMessage); |
588 iHostState->MessageNotificationReceivedL(aMessage); |
589 } |
589 } |
590 |
590 |
591 // --------------------------------------------------------------------------- |
591 // --------------------------------------------------------------------------- |
592 // |
592 // |
593 // --------------------------------------------------------------------------- |
593 // --------------------------------------------------------------------------- |
594 // |
594 // |
595 void CUsbOtgWatcher::BadHubPositionL() |
595 void CUsbOtgWatcher::BadHubPositionL() |
596 { |
596 { |
597 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
597 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
598 iHostState->BadHubPositionL(); |
598 iHostState->BadHubPositionL(); |
599 } |
599 } |
600 |
600 |
601 // --------------------------------------------------------------------------- |
601 // --------------------------------------------------------------------------- |
602 // |
602 // |
603 // --------------------------------------------------------------------------- |
603 // --------------------------------------------------------------------------- |
604 // |
604 // |
605 void CUsbOtgWatcher::VBusErrorL() |
605 void CUsbOtgWatcher::VBusErrorL() |
606 { |
606 { |
607 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
607 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
608 iHostState->VBusErrorL(); |
608 iHostState->VBusErrorL(); |
609 } |
609 } |
610 |
610 |
611 // --------------------------------------------------------------------------- |
611 // --------------------------------------------------------------------------- |
612 // |
612 // |
613 // --------------------------------------------------------------------------- |
613 // --------------------------------------------------------------------------- |
614 // |
614 // |
615 void CUsbOtgWatcher::SrpReceivedL() |
615 void CUsbOtgWatcher::SrpReceivedL() |
616 { |
616 { |
617 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
617 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
618 iHostState->SrpReceivedL(); |
618 iHostState->SrpReceivedL(); |
619 } |
619 } |
620 |
620 |
621 // --------------------------------------------------------------------------- |
621 // --------------------------------------------------------------------------- |
622 // |
622 // |
623 // --------------------------------------------------------------------------- |
623 // --------------------------------------------------------------------------- |
624 // |
624 // |
625 void CUsbOtgWatcher::SessionRequestedL() |
625 void CUsbOtgWatcher::SessionRequestedL() |
626 { |
626 { |
627 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
627 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
628 iHostState->SessionRequestedL(); |
628 iHostState->SessionRequestedL(); |
629 } |
629 } |
630 |
630 |
631 // --------------------------------------------------------------------------- |
631 // --------------------------------------------------------------------------- |
632 // |
632 // |
633 // --------------------------------------------------------------------------- |
633 // --------------------------------------------------------------------------- |
634 // |
634 // |
635 void CUsbOtgWatcher::MessageNotificationErrorL(TInt aError) |
635 void CUsbOtgWatcher::MessageNotificationErrorL(TInt aError) |
636 { |
636 { |
637 __ASSERT_DEBUG(iHostState != NULL, Panic(EBadHostState)); |
637 ASSERT_PANIC(iHostState != NULL, EBadHostState); |
638 HandleHostProblemL(EUsbWatcherMessageNotificationError, |
638 HandleHostProblemL(EUsbWatcherMessageNotificationError, |
639 EUsbStateHostHandleDropping); |
639 EUsbStateHostHandleDropping); |
640 } |
640 } |
641 |
641 |
642 // --------------------------------------------------------------------------- |
642 // --------------------------------------------------------------------------- |
1001 delete iMessageNotificationObserver; |
1018 delete iMessageNotificationObserver; |
1002 iMessageNotificationObserver = 0; |
1019 iMessageNotificationObserver = 0; |
1003 |
1020 |
1004 LOG("Creating states"); |
1021 LOG("Creating states"); |
1005 |
1022 |
1006 User::LeaveIfError(iStates.Append(CUsbStateHostUndefined::NewL(*this))); |
1023 LEAVEIFERROR(iStates.Append(CUsbStateHostUndefined::NewL(*this))); |
1007 User::LeaveIfError(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); |
1024 LEAVEIFERROR(iStates.Append(CUsbStateHostAInitiate::NewL(*this))); |
1008 User::LeaveIfError(iStates.Append(CUsbStateHostAHost::NewL(*this))); |
1025 LEAVEIFERROR(iStates.Append(CUsbStateHostAHost::NewL(*this))); |
1009 User::LeaveIfError(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); |
1026 LEAVEIFERROR(iStates.Append(CUsbStateHostAPeripheral::NewL(*this))); |
1010 User::LeaveIfError(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( |
1027 LEAVEIFERROR(iStates.Append(CUsbStateHostDelayAttachedHandle::NewL( |
1011 *this))); |
1028 *this))); |
1012 User::LeaveIfError(iStates.Append( |
1029 LEAVEIFERROR(iStates.Append( |
1013 CUsbStateHostDelayNotAttachedHandle::NewL(*this))); |
1030 CUsbStateHostDelayNotAttachedHandle::NewL(*this))); |
1014 User::LeaveIfError(iStates.Append( |
1031 LEAVEIFERROR(iStates.Append( |
1015 CUsbStateHostHandleDropping::NewL(*this))); |
1032 CUsbStateHostHandleDropping::NewL(*this))); |
1016 |
1033 |
1017 LOG("Check State()" ); |
1034 LOG("Check State()" ); |
1018 |
1035 |
1019 if (iStates[EUsbStateHostAInitiate] != State(EUsbStateHostAInitiate)) |
1036 if (iStates[EUsbStateHostAInitiate] != State(EUsbStateHostAInitiate)) |
1020 { |
1037 { |
1021 User::Leave(KErrGeneral); |
1038 LEAVE(KErrGeneral); |
1022 } |
1039 } |
1023 |
1040 |
1024 LOG("Check CurrentHostState()" ); |
1041 LOG("Check CurrentHostState()" ); |
1025 |
1042 |
1026 iHostState = iStates[EUsbStateHostAInitiate]; |
1043 iHostState = iStates[EUsbStateHostAInitiate]; |
1027 |
1044 |
1028 if (iStates[EUsbStateHostAInitiate] != CurrentHostState()) |
1045 if (iStates[EUsbStateHostAInitiate] != CurrentHostState()) |
1029 { |
1046 { |
1030 User::Leave(KErrGeneral); |
1047 LEAVE(KErrGeneral); |
1031 } |
1048 } |
1032 |
1049 |
1033 LOG("NotifManager and WarningNotifier." ); |
1050 LOG("NotifManager and WarningNotifier." ); |
1034 |
1051 |
1035 CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL(*this); |
1052 CUsbNotifManager* usbnotifmanager = CUsbNotifManager::NewL(*this); |
1036 RNotifier rnotifier; |
1053 RNotifier rnotifier; |
1037 User::LeaveIfError(rnotifier.Connect()); |
1054 LEAVEIFERROR(rnotifier.Connect()); |
1038 CUsbWarningNotifier* usbnotifier = CUsbWarningNotifier::NewL(rnotifier, |
1055 CUsbWarningNotifier* usbnotifier = CUsbWarningNotifier::NewL(rnotifier, |
1039 *usbnotifmanager, EUsbOtgPartiallySupportedDevice); |
1056 *usbnotifmanager, EUsbOtgPartiallySupportedDevice); |
1040 usbnotifier->IsFeedbackNeeded(); |
1057 usbnotifier->IsFeedbackNeeded(); |
1041 |
1058 |
1042 LOG( "NotifManager and WarningNotifier destruction." ); |
1059 LOG( "NotifManager and WarningNotifier destruction." ); |