2015. 7. 27. 00:22

Session Management 소개

Session Management

세션 관리

출처 : http://doc.qt.io/qt-4.8/session.html

session is a group of running applications, each of which has a particular state. The session is controlled by a service called the session manager. The applications participating in the session are called session clients.

세션 (session) 은 실행하고 있는 응용프로그램들의 묶음으로서, 각각 고유한 상태를 가지고 있습니다. 세션은 세션 관리자라고 불리는 서비스에서 제어되고 있습니다. 세션에 관여된 응용프로그램들을 세션 클라이언트들 (session clients) 이라고 불립니다.

The session manager issues commands to its clients on behalf of the user. These commands may cause clients to commit unsaved changes (for example by saving open files), to preserve their state for future sessions, or to terminate gracefully. The set of these operations is called session management.

세션 관리자는 사용자를 대신하여 자신의 클라이언트들에게 명령을 전달합니다. 이 명령들로 클라이언트에게 저장되지 않은 변경들을 저장시키게 (예를 들면, 열린 파일들을 저장) 하기, 이후 세션들을 위해 상태를 보존하기 또는 우아하게 종료시키게 해줍니다. 이러한 동작들으리 묶음을 세션 관리라고 부릅니다.

In the common case, a session consists of all applications that a user runs on their desktop at a time. Under Unix/X11, however, a session may include applications running on different computers and may span multiple displays.

흔한 사례로, 세션은 사용자가 데스크탑에서 각자 따로 동작 하고 있는 응용프로그램들을 구성하고 있습니다. 그러나, 유닉스/X11 에서는 세션은 다른 컴퓨터들과 멀티 디스플레이들까지 포함할 수 있습니다.

Shutting a Session Down

세션을 종료하기

A session is shut down by the session manager, usually on behalf of the user when they want to log out. A system might also perform an automatic shutdown in an emergency situation, for example, if power is about to be lost. Clearly there is a significant difference between these types of shutdown. During the first, the user may want to interact with the application, specifying exactly which files should be saved and which should be discarded. In the latter case, there's no time for interaction. There may not even be a user sitting in front of the machine!

보통 사용자가 로그 아웃을 원할 때, 사용자를 대신하여 세션 관리자에 의해 세션을 종료할 수 있습니다. 또한 예를 들어 전원 공급이 중단 될 경우와 같이 긴급한 경우 자동 종료를 수행할 수 있습니다. 분명 이들 종료들 간에도 분명한 차이는 있습니다. 전자(로그 아웃)의 경우, 사용자의 의도에 따른 동작으로 어떤 파일들이 저장되고, 어떤 건 버리게 할지를 정할 수 있습니다. 후자(전원 중단) 의 경우, 그렇게 반응할 시간이 없습니다. 심지어 그 때에는 사용자가 컴퓨터 앞에 앉아 있지 않는 경우도 있습니다.

Protocols and Support on Different Platforms

다른 플랫폼들에 대한 프로토콜과 지원

On Mac OS X, and Microsoft Windows versions prior to Windows 2000, there is nothing like complete session management for applications yet, i.e. no restoring of previous sessions. (Windows 2000 and XP provide "hibernation" where the entire memory is saved to disk and restored when the machine is restarted.) They do support graceful logouts where applications have the opportunity to cancel the process after getting confirmation from the user. This is the functionality that corresponds to the QApplication::commitData() method.

맥 OS X 와 윈도우 2000 이전의 마이크로소프트 윈도우들은 응용프로그램들을 위한 완벽한 세션 관리는 없었습니다, 다시 말하면  이전 세션의 복원같은 것은 없었습니다. (윈도우 2000 과 XP 는 (종료 이전에) 메모리를 전부 저장했었던 디스크에서 컴퓨터가 재시작시 복원하는 "최대절전" 을 제공합니다.) 그들은 (맥OS, 윈도우) 사용자로 부터 확인을 받은 뒤 수생하는 멋진 로그아웃 기능을 지원합니다. 이 기능은 QApplication::commitData() 메소드과 대응합니다.

X11 has supported complete session management since X11R6.

X11 은 X11R6 부터 완벽한 세션 관리를 지원합니다.

Getting Session Management to Work with Qt

세션 관리를 Qt 와 동작하게 하기

Start by reimplementing QApplication::commitData() to enable your application to take part in the graceful logout process. If you are only targeting the Microsoft Windows platform, this is all you can and must provide. Ideally, your application should provide a shutdown dialog similar to the following:

사용자의 응용프로그램이 멋진 로그아웃 동작에 참여할 수 있게하기 위해  QApplication::commitData() 를 재구현하는 것으로 시작합니다. 마이크로소프트 윈도우 플랫폼에만 맞춘다면, 이것이 전부이고 반드시 제공되야 합니다. 이상적으로, 당신의 응용프로그램은 종료 대화 상자를 아래와 같이 제공되야 합니다.



Example code for this dialog can be found in the documentation of QSessionManager::allowsInteraction().

이 대화상자에 대한 예제 코드는 QSessionManager::allowsInteraction() 문서에서 볼 수 있습니다.

For complete session management (only supported on X11R6 at present), you must also take care of saving the application's state, and potentially of restoring the state in the next life cycle of the session. This saving is done by reimplementing QApplication::saveState(). All state data you are saving in this function, should be marked with the session identifier QApplication::sessionId(). This application specific identifier is globally unique, so no clashes will occur. (See QSessionManager for information on saving/restoring the state of a particular Qt application.)

완벽한 세션 관리를 위해 (현재는 X11R6 에서만 지원), 당신은 또한 응용프로그램의 상태를 저장하고, 잠재적으로 다음 세션에 복원할 수 있는 부분까지 관리해야 합니다. 이 저장은 QApplication::saveState() 를 재구현하는 것으로 이뤄집니다. 이 함수를 통해 저장한 모든 상태 데이터는 세션 (고유)식별자인 QApplication::sessionId() 을 써서 표시되어야 합니다. 이 특정 식별자는 전역적으로 고유하므로 (다른 곳에서 같은 값이 생겨) 충돌이 나지 않습니다. (QSessionManager 에서 하나의 특정 Qt 응용프로그램의 상태를 저장하고/복원하는 것에 대한 정보를 볼 수 있습니다.)

Restoration is usually done in the application's main() function. Check if QApplication::isSessionRestored() is true. If that's the case, use the session identifier QApplication::sessionId() again to access your state data and restore the state of the application.

복원은 보통 응용프로그램의 main() 함수에서 이뤄집니다. QApplication::isSessionRestored() 값이 true 인지 확인합니다. 만약 그렇다면 세션 식별자인 QApplication::sessionId() 를 사용해 사용자의 상태 데이터를 접근하여 응용프로그램의 상태를 복원합니다.

Important: In order to allow the window manager to restore window attributes such as stacking order or geometry information, you must identify your top level widgets with unique application-wide object names (see QObject::setObjectName()). When restoring the application, you must ensure that all restored top level widgets are given the same unique names they had before.

중요: 윈도우 관리자가 윈도우가 쌓인 순서나 기하학 (예. 윈도우 모양/크기) 같은 윈도우 속성을 복원하기 위해, 사용자는 반드시 고유한 응용프로그램-범위의 객체 이름(QObject::setObjectName() 참고)을 사용하여 최상위 위젯을 구분해야 합니다. 응용프로그램을 복원할 때, 당신은 최상위 위젯들이 (저장) 이전에 주어진 고유한 이름과 같은 이름으로 복원 되어있어야 합니다.

Testing and Debugging Session Management

세션 관리를 시험하고 디버깅하기

Session management support on Mac OS X and Windows is fairly limited due to the lack of this functionality in the operating system itself. Simply shut the session down and verify that your application behaves as expected. It may be useful to launch another application, usually the integrated development environment, before starting your application. This other application will get the shutdown message afterwards, thus permitting you to cancel the shutdown. Otherwise you would have to log in again after each test run, which is not a problem per se, but is time consuming.

맥 OS X 와 윈도우에서 지원하는 세션 관리는 운영체제의 동작 자체의 기능제한으로 인해 순전히 제한적입니다. 단순히 세션을 닫고 예상대로 응용프로그램이 동작하는지 확인 합니다. 이는 통합 개발 환경 (IDE: 개발툴) 과 같이, 사용자의 응용프로그램을 실행하기 전에 다른 응용프로그램이 수행되는 환경에서 유용할 수 있습니다. (사용자가 개발한) 다른 응용프로그램이 종료 메시지를 받은 이후, 사용자가 종료를 취소시키는 것을 허용할 수 있습니다. 그렇지 않으면 당신은 매번 시험 수행한 이후 다시 로그인을 해야할 것이며, 그 자체로는 문제가 아니지만, 시간을 낭비하는 동작입니다.

On Unix you can either use a desktop environment that supports standard X11R6 session management or, the recommended method, use the session manager reference implementation provided by the X Consortium. This sample manager is called xsm and is part of a standard X11R6 installation. As always with X11, a useful and informative manual page is provided. Using xsm is straightforward (apart from the clumsy Athena-based user interface). Here's a simple approach:

유닉스에서는 X11R6 세션 관리 또는 X 콘소시움에서 제공한 세션 관리 기준 구현을 지원하는 데스크 탑 환경을 사용할 수 있습니다. 이 예제 관리자는 xsm 이라 불리고 표준 X11R6 설치 환경의 일부입니다. X11 에서 늘 그래왔듯이 유용하고 도움이 되는 설명서 페이지가 제공됩니다. (어설픈 Athena 기반 사용자 인터페이스를 제외하고) xsm 을 사용하면 직관적입니다.

  • Run X11R6.
  • X11R6 을 실행합니다.
  • Create a dot file .xsmstartup in your home directory which contains the single line
  • .xsmstartup 이라는 닷 파일 (숨김 속성의 설정파일) 을 사용자의 홈 디렉토리에 생성하고 다음의 한줄을 넣습니다.
xterm
  • This tells xsm that the default/failsafe session is just an xterm and nothing else. Otherwise xsm would try to invoke lots of clients including the windowmanager twm, which isn't very helpful.

  • 이는 xsm 에게 기본/안전모드 세션으로 단순히 xterm 이고 별다른게 아니라는 것을 알려줍니다. 그렇지 않으면 xsm 은 윈도우 관리자인 twm 을 포함해 많은 클라이언트들에게 알려줄 것이므로 도움이 되지 않습니다.

  • Now launch xsm from another terminal window. Both a session manager window and the xterm will appear. The xterm has a nice property that sets it apart from all the other shells you are currently running: within its shell, the SESSION_MANAGER environment variable points to the session manager you just started.
  • 이제 또다른 터미널 윈도우를 사용하여 xsm 을 실행합니다. 세션 관리자 윈도우와 xterm 모두 나타날 것입니다. 이 xterm 은 사용자가 현재 실행하고 있는 것들과는 별개로 멋진 속성을 가지고 있습니다 : 자신만의 쉘안에서 SESSION_MANAGER 환경 변수들은 사용자가 방금 시작한 세션 관리자를 가지키고 있습니다.
  • Launch your application from the new xterm window. It will connect itself automatically to the session manager. You can check with the ClientList push button whether the connect was successful.
  • 새로운 xterm 윈도우에서 당신의 응용프로그램을 실행하세요. 그 응용프로그램은 세션 관리자와 자동으로 연결될 것이고. ClientList 을 검사하여 그 연결이 성공적인지를 확인할 수 있습니다.
  • Note: Never keep the ClientList open when you start or end session managed clients! Otherwise xsm is likely to crash.
  • 참고: 세션을 시작하거나 종료하여 클라이언트들이 관리될 때 ClientList 를 열어 두시지 마시기 바랍니다! 그렇지 않으면 xsm 이 충돌 날 것입니다.

  • Use the session manager's Checkpoint and Shutdown buttons with different settings and see how your application behaves. The save type local means that the clients should save their state. It corresponds to the QApplication::saveState() function. The global save type asks applications to save their unsaved changes in permanent, globally accessible storage. It invokes QApplication::commitData().
  • 세션 관리자의 Checkpoint 와 Shutdown 버튼을 사용하여 사용자의 응용프로그램이 어떻게 동작하는지를 확인하세요. local 이라는 저장 형은 클라이언트들은 그들의 상태를 저장해야 합니다. 이는 QApplication::saveState() 함수에 대응합니다. global 이라는 저장 형은 저장되지 않은 변경들을 전역적으로 접근 가능한 저장소에 영구적으로 저장할 지 응용프로그램들에게 묻습니다.
  • Whenever something crashes, blame xsm and not Qt. xsm is far from being a usable session manager on a user's desktop. It is, however, stable and useful enough to serve as testing environment.
  • 뭔가 충돌 날때 마다, xsm 에게 비난하지 Qt 에게는 하지 말아 주세요. xsm 은 사용자의 데스크 탑에 있는 세션 관리자로서의 유용함과는 거리가 있습니다. 하지만 환경을 시험하는 용도로 쓸 만큼은 안정적이고 유용합니다.

© 2015 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.