LunaSysMgr
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
BannerMessageHandler.h
Go to the documentation of this file.
1 /* @@@LICENSE
2 *
3 * Copyright (c) 2009-2012 Hewlett-Packard Development Company, L.P.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 * LICENSE@@@ */
18 
19 
20 
21 
22 #ifndef BANNERMESSAGEHANDLER_H
23 #define BANNERMESSAGEHANDLER_H
24 
25 #include "Common.h"
26 
27 #include <string>
28 #include <QObject>
29 
30 #include "sptr.h"
31 #include "SoundPlayerPool.h"
32 
33 class QPainter;
34 
35 class BannerMessage;
36 class BannerMessageEvent;
38 
39 class ActiveCallBannerEvent;
40 
42 {
43 public:
44  enum ScrollType {
47  StatusBarScroll, // in this mode the Banner Message width chage, but the status bar is responsible for scrolling and clipping
49  };
50 
52  virtual ~BannerMessageView() {}
53 
55 
56  virtual int bmViewGetWidth() const = 0;
57  virtual int bmIsViewFullyExpanded() const { return false; }
58  virtual void bmViewUpdated() = 0;
59  virtual void bmViewMessageCountUpdated(int count) = 0;
60  virtual void bmViewShowingNonSuppressibleMessage(bool showing) = 0;
61 
62  virtual void bmViewAddActiveCallBanner(const std::string& msg, const std::string& icon, uint32_t time) = 0;
63  virtual void bmViewRemoveActiveCallBanner() = 0;
64  virtual void bmViewUpdateActiveCallBanner(const std::string& msg, const std::string& icon, uint32_t time) = 0;
65 
67 };
68 
70 {
71  Q_OBJECT
72 
73 public:
74 
76 
77  void registerView(BannerMessageView* view);
78 
80 
81  int viewHeight() const;
82 
83  qreal getViewContentWidth(const BannerMessageView* view);
84 
85  void drawView(QPainter* painter, const BannerMessageView* view);
86 
87  void handleBannerMessageEvent(BannerMessageEvent* e);
88 
89  void handleActiveCallBannerEvent(ActiveCallBannerEvent* e);
90 
91  void addMessage(const std::string& appId,
92  const std::string& msgId,
93  const std::string& msg,
94  const std::string& launchParams,
95  const std::string& icon,
96  const std::string& soundClass,
97  const std::string& soundFile,
98  int duration,
99  bool doNotSuppress);
100 
101  void removeMessage(const std::string& appId,
102  const std::string& msgId);
103 
104  void clearMessages(const std::string& appId);
105 
106  void activateCurrentMessage();
107 
108  sptr<SoundPlayer> playSound(const std::string& appId, const std::string& soundClass,
109  const std::string& soundFile, int duration, bool loop=false,
110  bool wakeupScreen=false);
111 
112 private:
113 
116 
117  void generateIcon(BannerMessage* m);
118  void setupState(BannerMessage* m, int viewWidth);
119  void playSound(BannerMessage* m);
120 
121  void paintBanner(QPainter* p, BannerMessage* m);
122 
123  int msgCount() const;
124 
125  bool isDefaultNotificationSound(const std::string& filePath) const;
126  bool isDefaultAlertSound(const std::string& filePath) const;
127  std::string pulseAudioSinkName(const std::string& streamClass) const;
128 
129 Q_SIGNALS:
130 
131  void signalHideBanner();
132 
133 private Q_SLOTS:
134 
135  void aboutToShowBanner();
136  void aboutToHideBanner();
137  void bannerPositionChanged();
138  void bannerStateMachineFinished();
139 
140 private:
141 
144 };
145 
146 #endif /* BANNERMESSAGEHANDLER_H */