summaryrefslogtreecommitdiff
path: root/libopie2
Unidiff
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_htc.cpp3
-rw-r--r--libopie2/opiepim/private/opimeventsortvector.cpp9
2 files changed, 4 insertions, 8 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp
index c21e10d..4e5200b 100644
--- a/libopie2/opiecore/device/odevice_htc.cpp
+++ b/libopie2/opiecore/device/odevice_htc.cpp
@@ -391,74 +391,73 @@ bool HTC::setDisplayBrightness( int bright )
391 391
392 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK ); 392 int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
393 if ( fd ) 393 if ( fd )
394 { 394 {
395 char buf[100]; 395 char buf[100];
396 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 396 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
397 res = ( ::write( fd, &buf[0], len ) == 0 ); 397 res = ( ::write( fd, &buf[0], len ) == 0 );
398 ::close( fd ); 398 ::close( fd );
399 } 399 }
400 return res; 400 return res;
401} 401}
402 402
403bool HTC::setDisplayStatus( bool on ) 403bool HTC::setDisplayStatus( bool on )
404{ 404{
405 405
406 bool res = false; 406 bool res = false;
407 407
408 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK ); 408 int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
409 if ( fd ) 409 if ( fd )
410 { 410 {
411 char buf[10]; 411 char buf[10];
412 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN; 412 buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
413 buf[1] = '\0'; 413 buf[1] = '\0';
414 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 414 res = ( ::write( fd, &buf[0], 2 ) == 0 );
415 ::close( fd ); 415 ::close( fd );
416 } 416 }
417 return res; 417 return res;
418} 418}
419 419
420Transformation HTC::rotation() const 420Transformation HTC::rotation() const
421{ 421{
422 qDebug( "HTC::rotation()" ); 422 qDebug( "HTC::rotation()" );
423 Transformation rot; 423 Transformation rot = Rot270;
424 424
425 switch ( d->m_model ) { 425 switch ( d->m_model ) {
426 case Model_HTC_Universal: 426 case Model_HTC_Universal:
427 { 427 {
428 OHingeStatus hs = readHingeSensor(); 428 OHingeStatus hs = readHingeSensor();
429 qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs ); 429 qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs );
430 if ( hs == CASE_PORTRAIT ) rot = Rot0; 430 if ( hs == CASE_PORTRAIT ) rot = Rot0;
431 else if ( hs == CASE_UNKNOWN ) rot = Rot270; 431 else if ( hs == CASE_UNKNOWN ) rot = Rot270;
432 else rot = Rot270;
433 } 432 }
434 break; 433 break;
435 } 434 }
436 435
437 qDebug( "HTC::rotation() - returning '%d'", rot ); 436 qDebug( "HTC::rotation() - returning '%d'", rot );
438 return rot; 437 return rot;
439} 438}
440ODirection HTC::direction() const 439ODirection HTC::direction() const
441{ 440{
442 ODirection dir; 441 ODirection dir;
443 442
444 switch ( d->m_model ) { 443 switch ( d->m_model ) {
445 case Model_HTC_Universal: { 444 case Model_HTC_Universal: {
446 OHingeStatus hs = readHingeSensor(); 445 OHingeStatus hs = readHingeSensor();
447 if ( hs == CASE_PORTRAIT ) dir = CCW; 446 if ( hs == CASE_PORTRAIT ) dir = CCW;
448 else if ( hs == CASE_UNKNOWN ) dir = CCW; 447 else if ( hs == CASE_UNKNOWN ) dir = CCW;
449 else dir = CW; 448 else dir = CW;
450 } 449 }
451 break; 450 break;
452 default: dir = d->m_direction; 451 default: dir = d->m_direction;
453 break; 452 break;
454 } 453 }
455 return dir; 454 return dir;
456 455
457} 456}
458 457
459bool HTC::hasHingeSensor() const 458bool HTC::hasHingeSensor() const
460{ 459{
461 return d->m_model == Model_HTC_Universal; 460 return d->m_model == Model_HTC_Universal;
462} 461}
463 462
464OHingeStatus HTC::readHingeSensor() const 463OHingeStatus HTC::readHingeSensor() const
diff --git a/libopie2/opiepim/private/opimeventsortvector.cpp b/libopie2/opiepim/private/opimeventsortvector.cpp
index 4220c63..b85f848 100644
--- a/libopie2/opiepim/private/opimeventsortvector.cpp
+++ b/libopie2/opiepim/private/opimeventsortvector.cpp
@@ -8,101 +8,98 @@
8.> <`_, > . <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i, .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - . .-<_> .<> Foundation; either version 2 of the License, 11 - . .-<_> .<> Foundation; either version 2 of the License,
12 ._= =} : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13 .%`+i> _;_. 13 .%`+i> _;_.
14 .i_,=:_. -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16 : .. .:, . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.= = ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++= -. .` .: details. 20++= -. .` .: details.
21 : = ...= . :.=- 21 : = ...= . :.=-
22 -. .:....=;==+<; You should have received a copy of the GNU 22 -. .:....=;==+<; You should have received a copy of the GNU
23 -_. . . )=. = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24 -- :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "opimeventsortvector.h" 30#include "opimeventsortvector.h"
31#include <opie2/ocontactaccess.h> 31#include <opie2/ocontactaccess.h>
32#include <opie2/opimnotifymanager.h> 32#include <opie2/opimnotifymanager.h>
33#include <opie2/odatebookaccess.h> 33#include <opie2/odatebookaccess.h>
34 34
35#include <qvaluelist.h> 35#include <qvaluelist.h>
36 36
37namespace Opie { 37namespace Opie {
38namespace Internal { 38namespace Internal {
39 39
40namespace{ 40int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){
41
42inline int testAlarmNotifiers( const OPimNotifyManager& leftnotifiers, const OPimNotifyManager& rightnotifiers ){
43 OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms(); 41 OPimNotifyManager::Alarms left_alarms = leftnotifiers.alarms();
44 OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms(); 42 OPimNotifyManager::Alarms right_alarms = rightnotifiers.alarms();
45 43
46 // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes 44 // Well.. How could we compare two lists of alarms? I think we should find the most early datetimes
47 // and compare them.. (se) 45 // and compare them.. (se)
48 // Find the first alarm of the left list 46 // Find the first alarm of the left list
49 OPimNotifyManager::Alarms::Iterator it; 47 OPimNotifyManager::Alarms::Iterator it;
50 QDateTime left_earliest; // This datetime is initialized as invalid!! 48 QDateTime left_earliest; // This datetime is initialized as invalid!!
51 for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){ 49 for ( it = left_alarms.begin(); it != left_alarms.end(); ++it ){
52 if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){ 50 if ( !left_earliest.isValid() || left_earliest > (*it).dateTime() ){
53 left_earliest = (*it).dateTime(); 51 left_earliest = (*it).dateTime();
54 } 52 }
55 } 53 }
56 QDateTime right_earliest; // This datetime is initialized as invalid!! 54 QDateTime right_earliest; // This datetime is initialized as invalid!!
57 for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){ 55 for ( it = right_alarms.begin(); it != right_alarms.end(); ++it ){
58 if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){ 56 if ( !right_earliest.isValid() || right_earliest > (*it).dateTime() ){
59 right_earliest = (*it).dateTime(); 57 right_earliest = (*it).dateTime();
60 } 58 }
61 } 59 }
62 60
63 int ret; 61 int ret = 0;
64 62
65 // Now compare this found alarms 63 // Now compare this found alarms
66 if ( !left_earliest .isValid() ) ret++; 64 if ( !left_earliest .isValid() ) ret++;
67 if ( !right_earliest.isValid() ) ret--; 65 if ( !right_earliest.isValid() ) ret--;
68 66
69 if ( left_earliest.isValid() && right_earliest.isValid() ){ 67 if ( left_earliest.isValid() && right_earliest.isValid() ){
70 ret += left_earliest < right_earliest ? -1 : 1; 68 left_earliest < right_earliest ? ret-- : ret++;
71 } 69 }
72 70
73 return ret; 71 return ret;
74 72
75} 73}
76}
77 74
78OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort ) 75OPimEventSortVector::OPimEventSortVector( uint size, bool asc, int sort )
79 : OPimSortVector<OPimEvent>( size, asc, sort ) {} 76 : OPimSortVector<OPimEvent>( size, asc, sort ) {}
80 77
81int OPimEventSortVector::compareItems( const OPimEvent& left, 78int OPimEventSortVector::compareItems( const OPimEvent& left,
82 const OPimEvent& right ) { 79 const OPimEvent& right ) {
83 if ( left.uid() == right.uid() ) 80 if ( left.uid() == right.uid() )
84 return 0; 81 return 0;
85 82
86 int ret = 0; 83 int ret = 0;
87 bool asc = sortAscending(); 84 bool asc = sortAscending();
88 85
89 switch( sortOrder() ) { 86 switch( sortOrder() ) {
90 case ODateBookAccess::SortDescription: 87 case ODateBookAccess::SortDescription:
91 ret = testString( left.description(), right.description() ); 88 ret = testString( left.description(), right.description() );
92 break; 89 break;
93 case ODateBookAccess::SortLocation: 90 case ODateBookAccess::SortLocation:
94 ret = testString( left.location(), right.location() ); 91 ret = testString( left.location(), right.location() );
95 break; 92 break;
96 case ODateBookAccess::SortNote: 93 case ODateBookAccess::SortNote:
97 ret = testString( left.note(),right.note() ); 94 ret = testString( left.note(),right.note() );
98 break; 95 break;
99 case ODateBookAccess::SortStartTime: 96 case ODateBookAccess::SortStartTime:
100 ret = testTime( left.startDateTime().time(), right.startDateTime().time() ); 97 ret = testTime( left.startDateTime().time(), right.startDateTime().time() );
101 break; 98 break;
102 case ODateBookAccess::SortEndTime: 99 case ODateBookAccess::SortEndTime:
103 ret = testTime( left.endDateTime().time(), right.endDateTime().time() ); 100 ret = testTime( left.endDateTime().time(), right.endDateTime().time() );
104 break; 101 break;
105 case ODateBookAccess::SortStartDate: 102 case ODateBookAccess::SortStartDate:
106 ret = testDate( left.startDateTime().date(), right.startDateTime().date() ); 103 ret = testDate( left.startDateTime().date(), right.startDateTime().date() );
107 break; 104 break;
108 case ODateBookAccess::SortEndDate: 105 case ODateBookAccess::SortEndDate: