summaryrefslogtreecommitdiffstats
path: root/wifi/asusled.cpp
blob: 19784c16a5cf22ff7443d9b99113f6e58f216311 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78

/***************************************************************************
                          led.cpp  -  description
                             -------------------
    begin                : wo okt 8 2003
    copyright            : (C) 2003 by Stefan Winter
    email                : [email protected]
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <fstream>
#include "asusled.h"

#include <kdebug.h>

Led::Led ()
{
  led = new std::ofstream ("/proc/acpi/asus/wled");

  // If there is no LED, just give a one time warning on cerr
  if (!(*led))
    {
      static bool error_given = false;
      if (!error_given)
	{
	  kdDebug () <<
	    "No Asus WLAN LED found, disabling LED updates" << endl;
	  error_given = true;
	}
    }
  Off ();
  // if Asusled not present, state never gets initialised, so we do it once here
  // so that valgrind doesn't complain.
  state = false;
}

Led::~Led ()
{

  Off ();
  delete led;

}


void
Led::On (void)
{

  if (*led)
    {
      *led << 1;
      led->flush ();
      state = true;
    }

}

void
Led::Off (void)
{

  if (*led)
    {
      *led << 0;
      led->flush ();
      state = false;
    }

}