<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/temp_scaffolding_stubs.h"

#include <vector>

#include "base/gfx/rect.h"
#include "base/logging.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/rlz/rlz.h"

#if defined(OS_LINUX)
#include "chrome/browser/dock_info.h"
#include "chrome/common/render_messages.h"
#endif

#if defined(OS_MACOSX)
#include "chrome/browser/automation/automation_provider.h"
#include "chrome/browser/fonts_languages_window.h"
#include "chrome/browser/memory_details.h"
#endif

#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_manager.h"
#include "chrome/browser/download/download_request_dialog_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#endif

class TabContents;

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
void AutomationProvider::GetAutocompleteEditForBrowser(
    int browser_handle,
    bool* success,
    int* autocomplete_edit_handle) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::GetAutocompleteEditText(int autocomplete_edit_handle,
                                                 bool* success,
                                                 std::wstring* text) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::SetAutocompleteEditText(int autocomplete_edit_handle,
                                                 const std::wstring& text,
                                                 bool* success) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::AutocompleteEditGetMatches(
    int autocomplete_edit_handle,
    bool* success,
    std::vector<AutocompleteMatchData>* matches) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::AutocompleteEditIsQueryInProgress(
    int autocomplete_edit_handle,
    bool* success,
    bool* query_in_progress) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::OnMessageFromExternalHost(
    int handle, const std::string& message, const std::string& origin,
    const std::string& target) {
  NOTIMPLEMENTED();
}

#endif  // defined(OS_MACOSX)

//--------------------------------------------------------------------------

// static
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
                                        const FilePath& master_prefs_path,
                                        std::vector<std::wstring>* new_tabs,
                                        int* ping_delay,
                                        bool* homepage_defined) {
  // http://code.google.com/p/chromium/issues/detail?id=11971
  // Pretend we processed them correctly.
  return true;
}

// static
int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
  // http://code.google.com/p/chromium/issues/detail?id=11971
  return 0;
}

bool FirstRun::CreateChromeDesktopShortcut() {
  NOTIMPLEMENTED();
  return false;
}

bool FirstRun::CreateChromeQuickLaunchShortcut() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool Upgrade::IsBrowserAlreadyRunning() {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return false;
}

// static
bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return true;
}

// static
bool Upgrade::SwapNewChromeExeIfPresent() {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return true;
}

// static
Upgrade::TryResult ShowTryChromeDialog(size_t version) {
  return Upgrade::TD_NOT_NOW;
}

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
void InstallJankometer(const CommandLine&) {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

void UninstallJankometer() {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}
#endif

//--------------------------------------------------------------------------

void RLZTracker::CleanupRlz() {
  // http://code.google.com/p/chromium/issues/detail?id=8152
}

bool RLZTracker::GetAccessPointRlz(AccessPoint point, std::wstring* rlz) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

bool RLZTracker::RecordProductEvent(Product product, AccessPoint point,
                                    Event event) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
MemoryDetails::MemoryDetails() {
  NOTIMPLEMENTED();
}

void MemoryDetails::StartFetch() {
  NOTIMPLEMENTED();
  OnDetailsAvailable();

  // When we get the real implementation this can be removed. The Release that
  // ends up deleting this object is done as the result of the PostTask in
  // CollectProcessData.
  Release();
}
#endif

#if defined(TOOLKIT_VIEWS)
// This should prompt the user if she wants to allow more than one concurrent
// download per tab. Until this is in place, always allow multiple downloads.
class DownloadRequestDialogDelegateStub
    : public DownloadRequestDialogDelegate {
 public:
  explicit DownloadRequestDialogDelegateStub(
    DownloadRequestManager::TabDownloadState* host)
      : DownloadRequestDialogDelegate(host) { DoCancel(); }

  virtual void CloseWindow() {}
};

DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
    TabContents* tab,
    DownloadRequestManager::TabDownloadState* host) {
  NOTIMPLEMENTED();
  return new DownloadRequestDialogDelegateStub(host);
}
#endif

#if !defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
namespace download_util {

void DragDownload(const DownloadItem* download,
                  SkBitmap* icon,
                  gfx::NativeView view) {
  NOTIMPLEMENTED();
}

}  // namespace download_util
#endif

#if !defined(TOOLKIT_VIEWS)
void BrowserList::AllBrowsersClosed() {
  // TODO(port): Close any dependent windows if necessary when the last browser
  //             window is closed.
}
#endif

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
bool DockInfo::GetNewWindowBounds(gfx::Rect* new_window_bounds,
                                  bool* maximize_new_window) const {
  // TODO(pinkerton): Implement on Mac.
  // http://crbug.com/9274
  return true;
}

void DockInfo::AdjustOtherWindowBounds() const {
  // TODO(pinkerton): Implement on Mac.
  // http://crbug.com/9274
}
#endif

//------------------------------------------------------------------------------

#if defined(OS_MACOSX)
void ShowFontsLanguagesWindow(gfx::NativeWindow window,
                              FontsLanguagesPage page,
                              Profile* profile) {
  NOTIMPLEMENTED();
}
#endif

//------------------------------------------------------------------------------

#if defined(TOOLKIT_VIEWS)

ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog(
    TabContents* owner,
    ConstrainedWindowDelegate* delegate) {
  NOTIMPLEMENTED();
  return NULL;
}

void BookmarkEditor::Show(gfx::NativeView parent_window,
                          Profile* profile,
                          const BookmarkNode* parent,
                          const BookmarkNode* node,
                          Configuration configuration,
                          Handler* handler) {
  NOTIMPLEMENTED();
}

void BookmarkManager::SelectInTree(Profile* profile, const BookmarkNode* node) {
}
void BookmarkManager::Show(Profile* profile) {
}

#endif

<commit_msg>[Mac] Make about:memory not crash.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/common/temp_scaffolding_stubs.h"

#include <vector>

#include "base/gfx/rect.h"
#include "base/logging.h"
#include "chrome/browser/browser_list.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/rlz/rlz.h"

#if defined(OS_LINUX)
#include "chrome/browser/dock_info.h"
#include "chrome/common/render_messages.h"
#endif

#if defined(OS_MACOSX)
#include "chrome/browser/automation/automation_provider.h"
#include "chrome/browser/fonts_languages_window.h"
#include "chrome/browser/memory_details.h"
#endif

#if defined(TOOLKIT_VIEWS)
#include "chrome/browser/bookmarks/bookmark_editor.h"
#include "chrome/browser/bookmarks/bookmark_manager.h"
#include "chrome/browser/download/download_request_dialog_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/tab_contents/constrained_window.h"
#endif

class TabContents;

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
void AutomationProvider::GetAutocompleteEditForBrowser(
    int browser_handle,
    bool* success,
    int* autocomplete_edit_handle) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::GetAutocompleteEditText(int autocomplete_edit_handle,
                                                 bool* success,
                                                 std::wstring* text) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::SetAutocompleteEditText(int autocomplete_edit_handle,
                                                 const std::wstring& text,
                                                 bool* success) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::AutocompleteEditGetMatches(
    int autocomplete_edit_handle,
    bool* success,
    std::vector<AutocompleteMatchData>* matches) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::AutocompleteEditIsQueryInProgress(
    int autocomplete_edit_handle,
    bool* success,
    bool* query_in_progress) {
  *success = false;
  NOTIMPLEMENTED();
}

void AutomationProvider::OnMessageFromExternalHost(
    int handle, const std::string& message, const std::string& origin,
    const std::string& target) {
  NOTIMPLEMENTED();
}

#endif  // defined(OS_MACOSX)

//--------------------------------------------------------------------------

// static
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
                                        const FilePath& master_prefs_path,
                                        std::vector<std::wstring>* new_tabs,
                                        int* ping_delay,
                                        bool* homepage_defined) {
  // http://code.google.com/p/chromium/issues/detail?id=11971
  // Pretend we processed them correctly.
  return true;
}

// static
int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
  // http://code.google.com/p/chromium/issues/detail?id=11971
  return 0;
}

bool FirstRun::CreateChromeDesktopShortcut() {
  NOTIMPLEMENTED();
  return false;
}

bool FirstRun::CreateChromeQuickLaunchShortcut() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool Upgrade::IsBrowserAlreadyRunning() {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return false;
}

// static
bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return true;
}

// static
bool Upgrade::SwapNewChromeExeIfPresent() {
  // http://code.google.com/p/chromium/issues/detail?id=9295
  return true;
}

// static
Upgrade::TryResult ShowTryChromeDialog(size_t version) {
  return Upgrade::TD_NOT_NOW;
}

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
void InstallJankometer(const CommandLine&) {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

void UninstallJankometer() {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}
#endif

//--------------------------------------------------------------------------

void RLZTracker::CleanupRlz() {
  // http://code.google.com/p/chromium/issues/detail?id=8152
}

bool RLZTracker::GetAccessPointRlz(AccessPoint point, std::wstring* rlz) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

bool RLZTracker::RecordProductEvent(Product product, AccessPoint point,
                                    Event event) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
MemoryDetails::MemoryDetails() {
  NOTIMPLEMENTED();
  process_data_.push_back(ProcessData());
}

void MemoryDetails::StartFetch() {
  NOTIMPLEMENTED();
  OnDetailsAvailable();

  // When we get the real implementation this can be removed. The Release that
  // ends up deleting this object is done as the result of the PostTask in
  // CollectProcessData.
  Release();
}
#endif

#if defined(TOOLKIT_VIEWS)
// This should prompt the user if she wants to allow more than one concurrent
// download per tab. Until this is in place, always allow multiple downloads.
class DownloadRequestDialogDelegateStub
    : public DownloadRequestDialogDelegate {
 public:
  explicit DownloadRequestDialogDelegateStub(
    DownloadRequestManager::TabDownloadState* host)
      : DownloadRequestDialogDelegate(host) { DoCancel(); }

  virtual void CloseWindow() {}
};

DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
    TabContents* tab,
    DownloadRequestManager::TabDownloadState* host) {
  NOTIMPLEMENTED();
  return new DownloadRequestDialogDelegateStub(host);
}
#endif

#if !defined(TOOLKIT_VIEWS) && !defined(OS_MACOSX)
namespace download_util {

void DragDownload(const DownloadItem* download,
                  SkBitmap* icon,
                  gfx::NativeView view) {
  NOTIMPLEMENTED();
}

}  // namespace download_util
#endif

#if !defined(TOOLKIT_VIEWS)
void BrowserList::AllBrowsersClosed() {
  // TODO(port): Close any dependent windows if necessary when the last browser
  //             window is closed.
}
#endif

//--------------------------------------------------------------------------

#if defined(OS_MACOSX)
bool DockInfo::GetNewWindowBounds(gfx::Rect* new_window_bounds,
                                  bool* maximize_new_window) const {
  // TODO(pinkerton): Implement on Mac.
  // http://crbug.com/9274
  return true;
}

void DockInfo::AdjustOtherWindowBounds() const {
  // TODO(pinkerton): Implement on Mac.
  // http://crbug.com/9274
}
#endif

//------------------------------------------------------------------------------

#if defined(OS_MACOSX)
void ShowFontsLanguagesWindow(gfx::NativeWindow window,
                              FontsLanguagesPage page,
                              Profile* profile) {
  NOTIMPLEMENTED();
}
#endif

//------------------------------------------------------------------------------

#if defined(TOOLKIT_VIEWS)

ConstrainedWindow* ConstrainedWindow::CreateConstrainedDialog(
    TabContents* owner,
    ConstrainedWindowDelegate* delegate) {
  NOTIMPLEMENTED();
  return NULL;
}

void BookmarkEditor::Show(gfx::NativeView parent_window,
                          Profile* profile,
                          const BookmarkNode* parent,
                          const BookmarkNode* node,
                          Configuration configuration,
                          Handler* handler) {
  NOTIMPLEMENTED();
}

void BookmarkManager::SelectInTree(Profile* profile, const BookmarkNode* node) {
}
void BookmarkManager::Show(Profile* profile) {
}

#endif

<|endoftext|>


<commit_before>#include "vtrc-endpoint-win-pipe.h"

#ifdef _WIN32

#include "boost/asio.hpp"
#include "boost/asio/windows/stream_handle.hpp"

#include "vtrc-application.h"
#include "vtrc-common/vtrc-enviroment.h"
#include "vtrc-common/vtrc-transport-win-pipe.h"
#include "vtrc-common/vtrc-connection-list.h"

#include "vtrc-endpoint-iface.h"
#include "vtrc-connection-impl.h"

namespace vtrc { namespace server { namespace endpoints {

namespace {

    namespace basio = boost::asio;
    typedef basio::windows::stream_handle    socket_type;
    typedef common::transport_win_pipe       connection_type;
    typedef connection_impl<connection_type> connection_impl_type;

    struct commection_pipe_impl: public connection_impl_type {

        typedef commection_pipe_impl this_type;

        commection_pipe_impl( endpoint_iface &endpoint,
                            vtrc::shared_ptr<socket_type> sock )
            :connection_impl_type(endpoint, sock)
        { }

        bool impersonate( )
        {
//            BOOL imp = ImpersonateNamedPipeClient(
//                                    get_socket( ).native_handle( ) );
//            if( imp ) {
//                common::call_context *c
//                                    (get_protocol(  ).get_top_call_context( ));
//                if( c ) c->set_impersonated( true );
//            }
//            return !!imp;
            return false;
        }

        void revert( )
        {
//            common::call_context *c
//                                (get_protocol( ).get_top_call_context( ));
//            if( c && c->get_impersonated( ) ) RevertToSelf( );
        }

        static vtrc::shared_ptr<this_type> create(endpoint_iface &endpoint,
                                         vtrc::shared_ptr<socket_type> sock )
        {
            vtrc::shared_ptr<this_type> new_inst
                    (vtrc::make_shared<this_type>(vtrc::ref(endpoint), sock));

            new_inst->init( );
            return new_inst;
        }
    };

    typedef commection_pipe_impl transport_type;

    struct pipe_ep_impl: public endpoint_iface {

        typedef pipe_ep_impl this_type;

        application             &app_;
        basio::io_service       &ios_;
        common::enviroment       env_;

        endpoint_options         opts_;
        std::string              endpoint_;
        size_t                   pipe_max_inst_;
        size_t                   in_buf_size_;
        size_t                   out_buf_size_;

        basio::windows::overlapped_ptr overlapped_;

        pipe_ep_impl( application &app,
                const endpoint_options &opts, const std::string pipe_name,
                size_t max_inst, size_t out_buf_size, size_t in_buf_size)
            :app_(app)
            ,ios_(app_.get_io_service( ))
            ,env_(app.get_enviroment( ))
            ,opts_(opts)
            ,endpoint_(pipe_name)
            ,pipe_max_inst_(max_inst)
            ,in_buf_size_(in_buf_size)
            ,out_buf_size_(out_buf_size)
        {}

        virtual ~pipe_ep_impl( ) { }

        application &get_application( )
        {
            return app_;
        }

        common::enviroment &get_enviroment( )
        {
            return env_;
        }

        std::string string( ) const
        {
            return std::string("pipe://") + endpoint_;
        }

        void start_accept(  )
        {
            SECURITY_DESCRIPTOR secdesc;
            SECURITY_ATTRIBUTES secarttr;
            InitializeSecurityDescriptor(&secdesc,
                                         SECURITY_DESCRIPTOR_REVISION);

            SetSecurityDescriptorDacl(&secdesc, TRUE,
                                      static_cast<PACL>(NULL), FALSE);

            secarttr.nLength              = sizeof(SECURITY_ATTRIBUTES);
            secarttr.bInheritHandle       = FALSE;
            secarttr.lpSecurityDescriptor = &secdesc;

            HANDLE pipe_hdl = CreateNamedPipeA( endpoint_.c_str( ),
                PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                PIPE_TYPE_BYTE     | PIPE_READMODE_BYTE,
                pipe_max_inst_,
                out_buf_size_, in_buf_size_,
                0, &secarttr );

            if( INVALID_HANDLE_VALUE != pipe_hdl ) {

                vtrc::shared_ptr<socket_type> new_sock
                        (vtrc::make_shared<socket_type>(vtrc::ref(ios_)));
                new_sock->assign( pipe_hdl );

                overlapped_.reset( ios_,
                        vtrc::bind( &this_type::on_accept, this,
                            basio::placeholders::error, new_sock) );

                BOOL res = ConnectNamedPipe( pipe_hdl, overlapped_.get( ) );

                DWORD last_error(GetLastError());
                if( res || ( last_error ==  ERROR_IO_PENDING ) ) {
                    overlapped_.release();

                } else if( last_error == ERROR_PIPE_CONNECTED ) {
                    bsys::error_code ec( 0,
                            basio::error::get_system_category( ));
                    overlapped_.complete( ec, 0 );

                } else {
                    bsys::error_code ec(last_error,
                                basio::error::get_system_category( ));
                    overlapped_.complete( ec, 0 );

                }
            } else {
                bsys::error_code ec(GetLastError( ),
                            basio::error::get_system_category( ));
                overlapped_.complete( ec, 0 );
            }
        }

        void start( )
        {
            start_accept( );
            app_.on_endpoint_started( this );
        }

        void stop ( )
        {
            app_.on_endpoint_stopped( this );
        }

        virtual const endpoint_options &get_options( ) const
        {
            return opts_;
        }

        void on_accept( const bsys::error_code &error,
                        vtrc::shared_ptr<socket_type> sock )
        {
            if( !error ) {
                try {
                    vtrc::shared_ptr<transport_type> new_conn
                             (transport_type::create( *this, sock ));
                    app_.get_clients( )->store( new_conn );
                } catch( ... ) {
                    ;;;
                }
                start_accept( );
            } else {
                // delete sock;
            }
        }

    };
}

    namespace win_pipe {

        endpoint_iface *create( application &app, const std::string &name )
        {
            endpoint_options def_opts(default_options( ));
            return new pipe_ep_impl( app, default_options( ), name,
                                     PIPE_UNLIMITED_INSTANCES,
                                     def_opts.read_buffer_size,
                                     def_opts.read_buffer_size );
        }

        //endpoint_iface *create( application &app, const std::wstring &name )
        //{
        //
        //}

        endpoint_iface *create( application &app, const endpoint_options &opts,
                                const std::string &name )
        {
            return new pipe_ep_impl( app, opts, name,
                                     PIPE_UNLIMITED_INSTANCES,
                                     opts.read_buffer_size,
                                     opts.read_buffer_size );
        }
    }

}}}

#endif
<commit_msg>fix winpipe<commit_after>#include "vtrc-endpoint-win-pipe.h"

#ifdef _WIN32

#include "boost/asio.hpp"
#include "boost/asio/windows/stream_handle.hpp"

#include "vtrc-application.h"
#include "vtrc-common/vtrc-enviroment.h"
#include "vtrc-common/vtrc-transport-win-pipe.h"
#include "vtrc-common/vtrc-connection-list.h"

#include "vtrc-endpoint-iface.h"
#include "vtrc-connection-impl.h"

#include "vtrc-atomic.h"
#include "vtrc-common/vtrc-closure.h"

namespace vtrc { namespace server { namespace endpoints {

namespace {

    namespace basio = boost::asio;
    typedef basio::windows::stream_handle    socket_type;
    typedef common::transport_win_pipe       connection_type;
    typedef connection_impl<connection_type> connection_impl_type;

    struct commection_pipe_impl: public connection_impl_type {

        typedef commection_pipe_impl this_type;

        commection_pipe_impl( endpoint_iface &endpoint,
                              vtrc::shared_ptr<socket_type> sock,
                              const common::empty_closure_type &on_destroy)
            :connection_impl_type(endpoint, sock, on_destroy)
        { }

        bool impersonate( )
        {
//            BOOL imp = ImpersonateNamedPipeClient(
//                                    get_socket( ).native_handle( ) );
//            if( imp ) {
//                common::call_context *c
//                                    (get_protocol(  ).get_top_call_context( ));
//                if( c ) c->set_impersonated( true );
//            }
//            return !!imp;
            return false;
        }

        void revert( )
        {
//            common::call_context *c
//                                (get_protocol( ).get_top_call_context( ));
//            if( c && c->get_impersonated( ) ) RevertToSelf( );
        }

        static vtrc::shared_ptr<this_type> create(endpoint_iface &endpoint,
                                 vtrc::shared_ptr<socket_type> sock,
                                 const common::empty_closure_type &on_destroy)
        {
            vtrc::shared_ptr<this_type> new_inst
                    (vtrc::make_shared<this_type>(vtrc::ref(endpoint),
                                                   sock, on_destroy));

            new_inst->init( );
            return new_inst;
        }
    };

    typedef commection_pipe_impl transport_type;

    struct pipe_ep_impl: public endpoint_iface {

        typedef pipe_ep_impl this_type;
        typedef vtrc::shared_ptr< vtrc::atomic<size_t> > shared_counter_type;

        application             &app_;
        basio::io_service       &ios_;
        common::enviroment       env_;

        endpoint_options         opts_;
        std::string              endpoint_;
        size_t                   pipe_max_inst_;
        size_t                   in_buf_size_;
        size_t                   out_buf_size_;
        shared_counter_type      client_count_;

        basio::windows::overlapped_ptr overlapped_;

        pipe_ep_impl( application &app,
                const endpoint_options &opts, const std::string pipe_name,
                size_t max_inst, size_t out_buf_size, size_t in_buf_size)
            :app_(app)
            ,ios_(app_.get_io_service( ))
            ,env_(app.get_enviroment( ))
            ,opts_(opts)
            ,endpoint_(pipe_name)
            ,pipe_max_inst_(max_inst)
            ,in_buf_size_(in_buf_size)
            ,out_buf_size_(out_buf_size)
            ,client_count_(vtrc::make_shared<vtrc::atomic<size_t> >(0))
        { }

        virtual ~pipe_ep_impl( ) { }

        static void on_client_destroy( shared_counter_type count )
        {
            --(*count);
        }

        common::empty_closure_type get_on_destroy( )
        {
            return vtrc::bind( &this_type::on_client_destroy, client_count_ );
        }

        application &get_application( )
        {
            return app_;
        }

        common::enviroment &get_enviroment( )
        {
            return env_;
        }

        std::string string( ) const
        {
            return std::string("pipe://") + endpoint_;
        }

        void start_accept(  )
        {
            SECURITY_DESCRIPTOR secdesc;
            SECURITY_ATTRIBUTES secarttr;
            InitializeSecurityDescriptor(&secdesc,
                                         SECURITY_DESCRIPTOR_REVISION);

            SetSecurityDescriptorDacl(&secdesc, TRUE,
                                      static_cast<PACL>(NULL), FALSE);

            secarttr.nLength              = sizeof(SECURITY_ATTRIBUTES);
            secarttr.bInheritHandle       = FALSE;
            secarttr.lpSecurityDescriptor = &secdesc;

            HANDLE pipe_hdl = CreateNamedPipeA( endpoint_.c_str( ),
                PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED,
                PIPE_TYPE_BYTE     | PIPE_READMODE_BYTE,
                pipe_max_inst_,
                out_buf_size_, in_buf_size_,
                0, &secarttr );

            if( INVALID_HANDLE_VALUE != pipe_hdl ) {

                vtrc::shared_ptr<socket_type> new_sock
                        (vtrc::make_shared<socket_type>(vtrc::ref(ios_)));
                new_sock->assign( pipe_hdl );

                overlapped_.reset( ios_,
                        vtrc::bind( &this_type::on_accept, this,
                            basio::placeholders::error, new_sock) );

                BOOL res = ConnectNamedPipe( pipe_hdl, overlapped_.get( ) );

                DWORD last_error(GetLastError());
                if( res || ( last_error ==  ERROR_IO_PENDING ) ) {
                    overlapped_.release();

                } else if( last_error == ERROR_PIPE_CONNECTED ) {
                    bsys::error_code ec( 0,
                            basio::error::get_system_category( ));
                    overlapped_.complete( ec, 0 );

                } else {
                    bsys::error_code ec(last_error,
                                basio::error::get_system_category( ));
                    overlapped_.complete( ec, 0 );

                }
            } else {
                bsys::error_code ec(GetLastError( ),
                            basio::error::get_system_category( ));
                overlapped_.complete( ec, 0 );
            }
        }

        void start( )
        {
            start_accept( );
            app_.on_endpoint_started( this );
        }

        void stop ( )
        {
            app_.on_endpoint_stopped( this );
        }

        virtual const endpoint_options &get_options( ) const
        {
            return opts_;
        }

        void on_accept( const bsys::error_code &error,
                        vtrc::shared_ptr<socket_type> sock )
        {
            if( !error ) {
                try {
                    vtrc::shared_ptr<transport_type> new_conn
                             (transport_type::create(
                                *this, sock, get_on_destroy( )));
                    app_.get_clients( )->store( new_conn );
                    ++(*client_count_);
                } catch( ... ) {
                    ;;;
                }
                start_accept( );
            } else {
                // delete sock;
            }
        }

    };
}

    namespace win_pipe {

        endpoint_iface *create( application &app, const std::string &name )
        {
            endpoint_options def_opts(default_options( ));
            return new pipe_ep_impl( app, default_options( ), name,
                                     PIPE_UNLIMITED_INSTANCES,
                                     def_opts.read_buffer_size,
                                     def_opts.read_buffer_size );
        }

        //endpoint_iface *create( application &app, const std::wstring &name )
        //{
        //
        //}

        endpoint_iface *create( application &app, const endpoint_options &opts,
                                const std::string &name )
        {
            return new pipe_ep_impl( app, opts, name,
                                     PIPE_UNLIMITED_INSTANCES,
                                     opts.read_buffer_size,
                                     opts.read_buffer_size );
        }
    }

}}}

#endif
<|endoftext|>


<commit_before>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "temp_scaffolding_stubs.h"

#include "build/build_config.h"

#include <vector>

#include "base/file_util.h"
#include "base/logging.h"
#include "base/thread.h"
#include "base/path_service.h"
#include "base/string_piece.h"
#include "base/singleton.h"
#include "base/task.h"
#include "chrome/browser/autocomplete/history_url_provider.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/debugger/debugger_shell.h"
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/download/download_request_dialog_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/memory_details.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_plugin_util.h"
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/process_watcher.h"
#include "net/url_request/url_request_context.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webkit_glue.h"

//--------------------------------------------------------------------------

bool ShellIntegration::SetAsDefaultBrowser() {
  NOTIMPLEMENTED();
  return true;
}

bool ShellIntegration::IsDefaultBrowser() {
  NOTIMPLEMENTED();
  return true;
}

//--------------------------------------------------------------------------

// static
bool FirstRun::IsChromeFirstRun() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
                                        const FilePath& master_prefs_path,
                                        int* preference_details) {
  NOTIMPLEMENTED();
  return false;
}

// static
int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
  NOTIMPLEMENTED();
  return 0;
}

// static
bool Upgrade::IsBrowserAlreadyRunning() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
  NOTIMPLEMENTED();
  return true;
}

// static
bool Upgrade::SwapNewChromeExeIfPresent() {
  NOTIMPLEMENTED();
  return true;
}

void OpenFirstRunDialog(Profile* profile) { NOTIMPLEMENTED(); }

//--------------------------------------------------------------------------

void InstallJankometer(const CommandLine&) {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

void UninstallJankometer() {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

//--------------------------------------------------------------------------

void TabContents::SetupController(Profile* profile) {
  DCHECK(!controller_);
  controller_ = new NavigationController(this, profile);
}

Profile* TabContents::profile() const {
  return controller_ ? controller_->profile() : NULL;
}

void TabContents::CloseContents() {
  // Destroy our NavigationController, which will Destroy all tabs it owns.
  controller_->Destroy();
  // Note that the controller may have deleted us at this point,
  // so don't touch any member variables here.
}

void TabContents::Destroy() {
  // TODO(pinkerton): this isn't the real version of Destroy(), just enough to
  // get the scaffolding working.

  is_being_destroyed_ = true;

  // Notify any observer that have a reference on this tab contents.
  NotificationService::current()->Notify(
      NotificationType::TAB_CONTENTS_DESTROYED,
      Source<TabContents>(this),
      NotificationService::NoDetails());

  // Notify our NavigationController.  Make sure we are deleted first, so
  // that the controller is the last to die.
  NavigationController* controller = controller_;
  TabContentsType type = this->type();

  delete this;

  controller->TabContentsWasDestroyed(type);
}

const GURL& TabContents::GetURL() const {
  // We may not have a navigation entry yet
  NavigationEntry* entry = controller_->GetActiveEntry();
  return entry ? entry->display_url() : GURL::EmptyGURL();
}

const std::wstring& TabContents::GetTitle() const {
  // We use the title for the last committed entry rather than a pending
  // navigation entry. For example, when the user types in a URL, we want to
  // keep the old page's title until the new load has committed and we get a new
  // title.
  // The exception is with transient pages, for which we really want to use
  // their title, as they are not committed.
  NavigationEntry* entry = controller_->GetTransientEntry();
  if (entry)
    return entry->GetTitleForDisplay();

  entry = controller_->GetLastCommittedEntry();
  if (entry)
    return entry->GetTitleForDisplay();
  else if (controller_->LoadingURLLazily())
    return controller_->GetLazyTitle();
  return EmptyWString();
}

void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) {
  if (delegate_)
    delegate_->NavigationStateChanged(this, changed_flags);
}

void TabContents::OpenURL(const GURL& url, const GURL& referrer,
                          WindowOpenDisposition disposition,
                          PageTransition::Type transition) {
  if (delegate_)
    delegate_->OpenURLFromTab(this, url, referrer, disposition, transition);
}

void TabContents::SetIsLoading(bool is_loading,
                               LoadNotificationDetails* details) {
  // TODO(port): this is a subset of SetIsLoading() as a stub
  is_loading_ = is_loading;
}

bool TabContents::SupportsURL(GURL* url) {
  GURL u(*url);
  if (TabContents::TypeForURL(&u) == type()) {
    *url = u;
    return true;
  }
  return false;
}

int32 TabContents::GetMaxPageID() {
  if (GetSiteInstance())
    return GetSiteInstance()->max_page_id();
  else
    return max_page_id_;
}

void TabContents::UpdateMaxPageID(int32 page_id) {
  // Ensure both the SiteInstance and RenderProcessHost update their max page
  // IDs in sync. Only WebContents will also have site instances, except during
  // testing.
  if (GetSiteInstance())
    GetSiteInstance()->UpdateMaxPageID(page_id);

  if (AsWebContents())
    AsWebContents()->process()->UpdateMaxPageID(page_id);
  else
    max_page_id_ = std::max(max_page_id_, page_id);
}

//--------------------------------------------------------------------------

void RLZTracker::CleanupRlz() {
  NOTIMPLEMENTED();
}

bool RLZTracker::GetAccessPointRlz(AccessPoint point, std::wstring* rlz) {
  NOTIMPLEMENTED();
  return false;
}

bool RLZTracker::RecordProductEvent(Product product, AccessPoint point,
                                    Event event) {
  NOTIMPLEMENTED();
  return false;
}

// This depends on porting all the plugin IPC messages.
bool IsPluginProcess() {
  return false;
}

//--------------------------------------------------------------------------

void RunJavascriptMessageBox(WebContents* web_contents,
                             int dialog_flags,
                             const std::wstring& message_text,
                             const std::wstring& default_prompt_text,
                             bool display_suppress_checkbox,
                             IPC::Message* reply_msg) {
  NOTIMPLEMENTED();
}

void RunBeforeUnloadDialog(WebContents* web_contents,
                           const std::wstring& message_text,
                           IPC::Message* reply_msg) {
  NOTIMPLEMENTED();
}

//--------------------------------------------------------------------------

void RunRepostFormWarningDialog(NavigationController*) {
}

LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
                                URLRequest* request,
                                MessageLoop* ui_loop) {
  NOTIMPLEMENTED();
  return NULL;
}

void ProcessWatcher::EnsureProcessTerminated(int) {
  NOTIMPLEMENTED();
}

//--------------------------------------------------------------------------
namespace webkit_glue {

bool IsDefaultPluginEnabled() {
  NOTIMPLEMENTED();
  return false;
}

#if defined(OS_MACOSX)
bool ClipboardIsFormatAvailable(Clipboard::FormatType format) {
  NOTIMPLEMENTED();
  return false;
}
#endif

}  // webkit_glue

#ifndef CHROME_DEBUGGER_DISABLED
DebuggerShell::DebuggerShell(DebuggerInputOutput *io) { }
DebuggerShell::~DebuggerShell() { }
void DebuggerShell::Start() { NOTIMPLEMENTED(); }
void DebuggerShell::Debug(TabContents* tab) { NOTIMPLEMENTED(); }
void DebuggerShell::DebugMessage(const std::wstring& msg) { NOTIMPLEMENTED(); }
void DebuggerShell::OnDebugAttach() { NOTIMPLEMENTED(); }
void DebuggerShell::OnDebugDisconnect() { NOTIMPLEMENTED(); }
void DebuggerShell::DidConnect() { NOTIMPLEMENTED(); }
void DebuggerShell::DidDisconnect() { NOTIMPLEMENTED(); }
void DebuggerShell::ProcessCommand(const std::wstring& data) {
  NOTIMPLEMENTED();
}
#endif  // !CHROME_DEBUGGER_DISABLED

MemoryDetails::MemoryDetails() {
  NOTIMPLEMENTED();
}

void MemoryDetails::StartFetch() {
  NOTIMPLEMENTED();
}

InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

InfoBar* AlertInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

InfoBar* LinkInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

bool CanImportURL(const GURL& url) {
  NOTIMPLEMENTED();
  return false;
}

DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
    TabContents* tab,
    DownloadRequestManager::TabDownloadState* host) {
  NOTIMPLEMENTED();
  return NULL;
}

views::Window* CreateInputWindow(gfx::NativeWindow parent_hwnd,
                                 InputWindowDelegate* delegate) {
  NOTIMPLEMENTED();
  return new views::Window();
}

<commit_msg>RLZ NOTIMPLEMENTEDs -> bug.<commit_after>// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "temp_scaffolding_stubs.h"

#include "build/build_config.h"

#include <vector>

#include "base/file_util.h"
#include "base/logging.h"
#include "base/thread.h"
#include "base/path_service.h"
#include "base/string_piece.h"
#include "base/singleton.h"
#include "base/task.h"
#include "chrome/browser/autocomplete/history_url_provider.h"
#include "chrome/browser/browser.h"
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/cache_manager_host.h"
#include "chrome/browser/debugger/debugger_shell.h"
#include "chrome/browser/dom_ui/dom_ui.h"
#include "chrome/browser/download/download_request_dialog_delegate.h"
#include "chrome/browser/download/download_request_manager.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/history/in_memory_history_backend.h"
#include "chrome/browser/memory_details.h"
#include "chrome/browser/profile_manager.h"
#include "chrome/browser/renderer_host/render_widget_helper.h"
#include "chrome/browser/renderer_host/resource_message_filter.h"
#include "chrome/browser/rlz/rlz.h"
#include "chrome/browser/search_engines/template_url_prepopulate_data.h"
#include "chrome/browser/shell_integration.h"
#include "chrome/browser/tab_contents/web_contents.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_plugin_util.h"
#include "chrome/common/gfx/chrome_font.h"
#include "chrome/common/gfx/text_elider.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_service.h"
#include "chrome/common/process_watcher.h"
#include "net/url_request/url_request_context.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webkit_glue.h"

//--------------------------------------------------------------------------

bool ShellIntegration::SetAsDefaultBrowser() {
  NOTIMPLEMENTED();
  return true;
}

bool ShellIntegration::IsDefaultBrowser() {
  NOTIMPLEMENTED();
  return true;
}

//--------------------------------------------------------------------------

// static
bool FirstRun::IsChromeFirstRun() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool FirstRun::ProcessMasterPreferences(const FilePath& user_data_dir,
                                        const FilePath& master_prefs_path,
                                        int* preference_details) {
  NOTIMPLEMENTED();
  return false;
}

// static
int FirstRun::ImportNow(Profile* profile, const CommandLine& cmdline) {
  NOTIMPLEMENTED();
  return 0;
}

// static
bool Upgrade::IsBrowserAlreadyRunning() {
  NOTIMPLEMENTED();
  return false;
}

// static
bool Upgrade::RelaunchChromeBrowser(const CommandLine& command_line) {
  NOTIMPLEMENTED();
  return true;
}

// static
bool Upgrade::SwapNewChromeExeIfPresent() {
  NOTIMPLEMENTED();
  return true;
}

void OpenFirstRunDialog(Profile* profile) { NOTIMPLEMENTED(); }

//--------------------------------------------------------------------------

void InstallJankometer(const CommandLine&) {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

void UninstallJankometer() {
  // http://code.google.com/p/chromium/issues/detail?id=8077
}

//--------------------------------------------------------------------------

void TabContents::SetupController(Profile* profile) {
  DCHECK(!controller_);
  controller_ = new NavigationController(this, profile);
}

Profile* TabContents::profile() const {
  return controller_ ? controller_->profile() : NULL;
}

void TabContents::CloseContents() {
  // Destroy our NavigationController, which will Destroy all tabs it owns.
  controller_->Destroy();
  // Note that the controller may have deleted us at this point,
  // so don't touch any member variables here.
}

void TabContents::Destroy() {
  // TODO(pinkerton): this isn't the real version of Destroy(), just enough to
  // get the scaffolding working.

  is_being_destroyed_ = true;

  // Notify any observer that have a reference on this tab contents.
  NotificationService::current()->Notify(
      NotificationType::TAB_CONTENTS_DESTROYED,
      Source<TabContents>(this),
      NotificationService::NoDetails());

  // Notify our NavigationController.  Make sure we are deleted first, so
  // that the controller is the last to die.
  NavigationController* controller = controller_;
  TabContentsType type = this->type();

  delete this;

  controller->TabContentsWasDestroyed(type);
}

const GURL& TabContents::GetURL() const {
  // We may not have a navigation entry yet
  NavigationEntry* entry = controller_->GetActiveEntry();
  return entry ? entry->display_url() : GURL::EmptyGURL();
}

const std::wstring& TabContents::GetTitle() const {
  // We use the title for the last committed entry rather than a pending
  // navigation entry. For example, when the user types in a URL, we want to
  // keep the old page's title until the new load has committed and we get a new
  // title.
  // The exception is with transient pages, for which we really want to use
  // their title, as they are not committed.
  NavigationEntry* entry = controller_->GetTransientEntry();
  if (entry)
    return entry->GetTitleForDisplay();

  entry = controller_->GetLastCommittedEntry();
  if (entry)
    return entry->GetTitleForDisplay();
  else if (controller_->LoadingURLLazily())
    return controller_->GetLazyTitle();
  return EmptyWString();
}

void TabContents::NotifyNavigationStateChanged(unsigned changed_flags) {
  if (delegate_)
    delegate_->NavigationStateChanged(this, changed_flags);
}

void TabContents::OpenURL(const GURL& url, const GURL& referrer,
                          WindowOpenDisposition disposition,
                          PageTransition::Type transition) {
  if (delegate_)
    delegate_->OpenURLFromTab(this, url, referrer, disposition, transition);
}

void TabContents::SetIsLoading(bool is_loading,
                               LoadNotificationDetails* details) {
  // TODO(port): this is a subset of SetIsLoading() as a stub
  is_loading_ = is_loading;
}

bool TabContents::SupportsURL(GURL* url) {
  GURL u(*url);
  if (TabContents::TypeForURL(&u) == type()) {
    *url = u;
    return true;
  }
  return false;
}

int32 TabContents::GetMaxPageID() {
  if (GetSiteInstance())
    return GetSiteInstance()->max_page_id();
  else
    return max_page_id_;
}

void TabContents::UpdateMaxPageID(int32 page_id) {
  // Ensure both the SiteInstance and RenderProcessHost update their max page
  // IDs in sync. Only WebContents will also have site instances, except during
  // testing.
  if (GetSiteInstance())
    GetSiteInstance()->UpdateMaxPageID(page_id);

  if (AsWebContents())
    AsWebContents()->process()->UpdateMaxPageID(page_id);
  else
    max_page_id_ = std::max(max_page_id_, page_id);
}

//--------------------------------------------------------------------------

void RLZTracker::CleanupRlz() {
  // http://code.google.com/p/chromium/issues/detail?id=8152
}

bool RLZTracker::GetAccessPointRlz(AccessPoint point, std::wstring* rlz) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

bool RLZTracker::RecordProductEvent(Product product, AccessPoint point,
                                    Event event) {
  // http://code.google.com/p/chromium/issues/detail?id=8152
  return false;
}

// This depends on porting all the plugin IPC messages.
bool IsPluginProcess() {
  return false;
}

//--------------------------------------------------------------------------

void RunJavascriptMessageBox(WebContents* web_contents,
                             int dialog_flags,
                             const std::wstring& message_text,
                             const std::wstring& default_prompt_text,
                             bool display_suppress_checkbox,
                             IPC::Message* reply_msg) {
  NOTIMPLEMENTED();
}

void RunBeforeUnloadDialog(WebContents* web_contents,
                           const std::wstring& message_text,
                           IPC::Message* reply_msg) {
  NOTIMPLEMENTED();
}

//--------------------------------------------------------------------------

void RunRepostFormWarningDialog(NavigationController*) {
}

LoginHandler* CreateLoginPrompt(net::AuthChallengeInfo* auth_info,
                                URLRequest* request,
                                MessageLoop* ui_loop) {
  NOTIMPLEMENTED();
  return NULL;
}

void ProcessWatcher::EnsureProcessTerminated(int) {
  NOTIMPLEMENTED();
}

//--------------------------------------------------------------------------
namespace webkit_glue {

bool IsDefaultPluginEnabled() {
  NOTIMPLEMENTED();
  return false;
}

#if defined(OS_MACOSX)
bool ClipboardIsFormatAvailable(Clipboard::FormatType format) {
  NOTIMPLEMENTED();
  return false;
}
#endif

}  // webkit_glue

#ifndef CHROME_DEBUGGER_DISABLED
DebuggerShell::DebuggerShell(DebuggerInputOutput *io) { }
DebuggerShell::~DebuggerShell() { }
void DebuggerShell::Start() { NOTIMPLEMENTED(); }
void DebuggerShell::Debug(TabContents* tab) { NOTIMPLEMENTED(); }
void DebuggerShell::DebugMessage(const std::wstring& msg) { NOTIMPLEMENTED(); }
void DebuggerShell::OnDebugAttach() { NOTIMPLEMENTED(); }
void DebuggerShell::OnDebugDisconnect() { NOTIMPLEMENTED(); }
void DebuggerShell::DidConnect() { NOTIMPLEMENTED(); }
void DebuggerShell::DidDisconnect() { NOTIMPLEMENTED(); }
void DebuggerShell::ProcessCommand(const std::wstring& data) {
  NOTIMPLEMENTED();
}
#endif  // !CHROME_DEBUGGER_DISABLED

MemoryDetails::MemoryDetails() {
  NOTIMPLEMENTED();
}

void MemoryDetails::StartFetch() {
  NOTIMPLEMENTED();
}

InfoBar* ConfirmInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

InfoBar* AlertInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

InfoBar* LinkInfoBarDelegate::CreateInfoBar() {
  NOTIMPLEMENTED();
  return NULL;
}

bool CanImportURL(const GURL& url) {
  NOTIMPLEMENTED();
  return false;
}

DownloadRequestDialogDelegate* DownloadRequestDialogDelegate::Create(
    TabContents* tab,
    DownloadRequestManager::TabDownloadState* host) {
  NOTIMPLEMENTED();
  return NULL;
}

views::Window* CreateInputWindow(gfx::NativeWindow parent_hwnd,
                                 InputWindowDelegate* delegate) {
  NOTIMPLEMENTED();
  return new views::Window();
}

<|endoftext|>


<commit_before>
/*
  Copyright 1995 The University of Rhode Island and The Massachusetts
  Institute of Technology

  Portions of this software were developed by the Graduate School of
  Oceanography (GSO) at the University of Rhode Island (URI) in collaboration
  with The Massachusetts Institute of Technology (MIT).

  Access and use of this software shall impose the following obligations and
  understandings on the user. The user is granted the right, without any fee
  or cost, to use, copy, modify, alter, enhance and distribute this software,
  and any derivative works thereof, and its supporting documentation for any
  purpose whatsoever, provided that this entire notice appears in all copies
  of the software, derivative works and supporting documentation.  Further,
  the user agrees to credit URI/MIT in any publications that result from the
  use of this software or in any product that includes this software. The
  names URI, MIT and/or GSO, however, may not be used in any advertising or
  publicity to endorse or promote any products or commercial entity unless
  specific written permission is obtained from URI/MIT. The user also
  understands that URI/MIT is not obligated to provide the user with any
  support, consulting, training or assistance of any kind with regard to the
  use, operation and performance of this software nor to provide the user
  with any updates, revisions, new versions or "bug fixes".

  THIS SOFTWARE IS PROVIDED BY URI/MIT "AS IS" AND ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  EVENT SHALL URI/MIT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS
  ACTION, ARISING OUT OF OR IN CONNECTION WITH THE ACCESS, USE OR PERFORMANCE
  OF THIS SOFTWARE.
*/

// Implementation for TestArray. See TestByte.cc
//
// jhrg 1/12/95

// $Log: TestArray.cc,v $
// Revision 1.7  1995/07/09 21:29:07  jimg
// Added copyright notice.
//
// Revision 1.6  1995/05/10  13:45:34  jimg
// Changed the name of the configuration header file from `config.h' to
// `config_dap.h' so that other libraries could have header files which were
// installed in the DODS include directory without overwriting this one. Each
// config header should follow the convention config_<name>.h.
//
// Revision 1.5  1995/03/16  17:32:27  jimg
// Fixed bugs with read()s new & delete calls.
//
// Revision 1.4  1995/03/04  14:38:00  jimg
// Modified these so that they fit with the changes in the DAP classes.
//
// Revision 1.3  1995/02/10  02:33:37  jimg
// Modified Test<class>.h and .cc so that they used to new definitions of
// read_val().
// Modified the classes read() so that they are more in line with the
// class library's intended use in a real subclass set.
//
// Revision 1.2  1995/01/19  21:58:50  jimg
// Added read_val from dummy_read.cc to the sample set of sub-class
// implementations.
// Changed the declaration of readVal in BaseType so that it names the
// mfunc read_val (to be consistant with the other mfunc names).
// Removed the unnecessary duplicate declaration of the abstract virtual
// mfuncs read and (now) read_val from the classes Byte, ... Grid. The
// declaration in BaseType is sufficient along with the decl and definition
// in the *.cc,h files which contain the subclasses for Byte, ..., Grid.
//
// Revision 1.1  1995/01/19  20:20:34  jimg
// Created as an example of subclassing the class hierarchy rooted at
// BaseType.
//

#ifdef __GNUG__
#pragma implementation
#endif

#include "config_dap.h"

#include <assert.h>

#include "TestArray.h"

#ifdef TRACE_NEW
#include "trace_new.h"
#endif

Array *
NewArray(const String &n, BaseType *v)
{
    return new TestArray(n, v);
}

BaseType *
TestArray::ptr_duplicate()
{
    return new TestArray(*this);
}

TestArray::TestArray(const String &n, BaseType *v) : Array(n, v)
{
}

TestArray::~TestArray()
{
}

bool
TestArray::read(String dataset, String var_name, String constraint)
{
    unsigned int wid = var()->width(); // size of the contained variable

    // run read() on the contained variable to get, via the read() mfuncs
    // defined in the other Test classes, a value in the *contained* object.
    var()->read(dataset, var_name, constraint);

    // OK, now make an array of those things, and copy the value length()
    // times.
    unsigned int len = length();
    char *tmp = new char[width()];
    void *elem_val = 0;		// the null forces a new object to be
				// allocated

    var()->read_val(&elem_val);	// read_val() allocates space as an array...

    for (int i = 0; i < len; ++i)
	memcpy(tmp + i * wid, elem_val, wid);

    store_val(tmp);

    delete[] elem_val;
    delete[] tmp;
}
<commit_msg>Fixed the read() member function so that it works correctly for arrays/lists of Structure, ... types.<commit_after>
/*
  Copyright 1995 The University of Rhode Island and The Massachusetts
  Institute of Technology

  Portions of this software were developed by the Graduate School of
  Oceanography (GSO) at the University of Rhode Island (URI) in collaboration
  with The Massachusetts Institute of Technology (MIT).

  Access and use of this software shall impose the following obligations and
  understandings on the user. The user is granted the right, without any fee
  or cost, to use, copy, modify, alter, enhance and distribute this software,
  and any derivative works thereof, and its supporting documentation for any
  purpose whatsoever, provided that this entire notice appears in all copies
  of the software, derivative works and supporting documentation.  Further,
  the user agrees to credit URI/MIT in any publications that result from the
  use of this software or in any product that includes this software. The
  names URI, MIT and/or GSO, however, may not be used in any advertising or
  publicity to endorse or promote any products or commercial entity unless
  specific written permission is obtained from URI/MIT. The user also
  understands that URI/MIT is not obligated to provide the user with any
  support, consulting, training or assistance of any kind with regard to the
  use, operation and performance of this software nor to provide the user
  with any updates, revisions, new versions or "bug fixes".

  THIS SOFTWARE IS PROVIDED BY URI/MIT "AS IS" AND ANY EXPRESS OR IMPLIED
  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  EVENT SHALL URI/MIT BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
  DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTUOUS
  ACTION, ARISING OUT OF OR IN CONNECTION WITH THE ACCESS, USE OR PERFORMANCE
  OF THIS SOFTWARE.
*/

// Implementation for TestArray. See TestByte.cc
//
// jhrg 1/12/95

// $Log: TestArray.cc,v $
// Revision 1.8  1995/08/23 00:50:01  jimg
// Fixed the read() member function so that it works correctly for arrays/lists
// of Structure, ... types.
//
// Revision 1.7  1995/07/09  21:29:07  jimg
// Added copyright notice.
//
// Revision 1.6  1995/05/10  13:45:34  jimg
// Changed the name of the configuration header file from `config.h' to
// `config_dap.h' so that other libraries could have header files which were
// installed in the DODS include directory without overwriting this one. Each
// config header should follow the convention config_<name>.h.
//
// Revision 1.5  1995/03/16  17:32:27  jimg
// Fixed bugs with read()s new & delete calls.
//
// Revision 1.4  1995/03/04  14:38:00  jimg
// Modified these so that they fit with the changes in the DAP classes.
//
// Revision 1.3  1995/02/10  02:33:37  jimg
// Modified Test<class>.h and .cc so that they used to new definitions of
// read_val().
// Modified the classes read() so that they are more in line with the
// class library's intended use in a real subclass set.
//
// Revision 1.2  1995/01/19  21:58:50  jimg
// Added read_val from dummy_read.cc to the sample set of sub-class
// implementations.
// Changed the declaration of readVal in BaseType so that it names the
// mfunc read_val (to be consistant with the other mfunc names).
// Removed the unnecessary duplicate declaration of the abstract virtual
// mfuncs read and (now) read_val from the classes Byte, ... Grid. The
// declaration in BaseType is sufficient along with the decl and definition
// in the *.cc,h files which contain the subclasses for Byte, ..., Grid.
//
// Revision 1.1  1995/01/19  20:20:34  jimg
// Created as an example of subclassing the class hierarchy rooted at
// BaseType.
//

#ifdef __GNUG__
#pragma implementation
#endif

#include "config_dap.h"

#include <assert.h>

#include "TestArray.h"

#ifdef TRACE_NEW
#include "trace_new.h"
#endif

Array *
NewArray(const String &n, BaseType *v)
{
    return new TestArray(n, v);
}

BaseType *
TestArray::ptr_duplicate()
{
    return new TestArray(*this);
}

TestArray::TestArray(const String &n, BaseType *v) : Array(n, v)
{
}

TestArray::~TestArray()
{
}

// This read mfunc does some strange things to get a value - a real program
// would never get values this way. For testing this is OK.

bool
TestArray::read(String dataset, String var_name, String constraint)
{
    int i;

    // run read() on the contained variable to get, via the read() mfuncs
    // defined in the other Test classes, a value in the *contained* object.
    var()->read(dataset, var_name, constraint);

    unsigned int array_len = length(); // elements in the array

    switch (var()->type()) {
      case byte_t:
      case int32_t:
      case float64_t:
      case str_t:
      case url_t:

	// String and Url are grouped with byte, ... because val2buf works
	// for these types.

	unsigned int elem_wid = var()->width(); // size of an element

	char *tmp = new char[width()];
	void *elem_val = 0;	// NULL init gets read_val() to alloc space

	var()->buf2val(&elem_val); // internal buffer to ELEM_VAL

	for (i = 0; i < array_len; ++i)
	    memcpy(tmp + i * elem_wid, elem_val, elem_wid);

	val2buf(tmp);

	delete[] elem_val;	// alloced in read_val()
	delete[] tmp;		// alloced above

	break;

      case list_t:
      case structure_t:
      case sequence_t:
      case function_t:
      case grid_t:

	// Arrays of Structure, ... must load each element into the array
	// manually. Because these are stored as C++/DODS objects, there is
	// no need to manipulate blocks of memory by hand as in the above
	// case.
        // NB: Strings are handled like Byte, etc. because, even though they
	// are represented using C++ objects they are *not* represented using
	// objects defined by DODS, while Structure, etc. are.

	for (i = 0; i < array_len; ++i) {

	    // Create a new object that is a copy of `var()' (whatever that
	    // is. The copy will have the value rad in by the read() mfunc
	    // executed before this switch stmt.

	    BaseType *elem = var()->ptr_duplicate();

	    // now load the new instance in the array.

	    set_vec(i, elem);
	}

	break;

    }

    return true;
}
<|endoftext|>


<commit_before>//  File: linuxHostsupport.cpp
//      John Manferdelli
//  Description:  Support for Linux host as trusted OS
//
//  Copyright (c) 2012, John Manferdelli
//  Some contributions copyright (c) 2012, Intel Corporation
//
// Use, duplication and disclosure of this file and derived works of
// this file are subject to and licensed under the Apache License dated
// January, 2004, (the "License").  This License is contained in the
// top level directory originally provided with the CloudProxy Project.
// Your right to use or distribute this file, or derived works thereof,
// is subject to your being bound by those terms and your use indicates
// consent to those terms.
//
// If you distribute this file (or portions derived therefrom), you must
// include License in or with the file and, in the event you do not include
// the entire License in the file, the file must contain a reference
// to the location of the License.

#include "jlmTypes.h"
#include "logging.h"
#include "jlmcrypto.h"
#include "jlmUtility.h"
#include "modesandpadding.h"
#include "sha256.h"
#include "tao.h"
#include "bignum.h"
#include "mpFunctions.h"
#include "cryptoHelper.h"
#include "trustedKeyNego.h"
#include "tcIO.h"
#include "buffercoding.h"
#include "tcService.h"
#include <string.h>
#include <time.h>

// -------------------------------------------------------------------------

//
//   Service support from LINUX
//

// request channel to device driver
tcChannel   g_reqChannel;
int         g_myPid= -1;

bool initLinuxService(const char* name)
{
#ifdef TCTEST
    if(name!=NULL)
        fprintf(g_logFile, "initLinuxService started %s\n", name);
    else
        fprintf(g_logFile, "initLinuxService started no childname\n");
#endif

    g_myPid= getpid();
    if(!g_reqChannel.OpenBuf(TCDEVICEDRIVER, 0, name ,0)) {
        fprintf(g_logFile, "initLinuxService: OpenBuf returned false \n");
        return false;
    }

#ifdef TCTEST
    fprintf(g_logFile, "initLinuxService returns true\n");
#endif
    return true;
}

bool closeLinuxService()
{
    g_reqChannel.CloseBuf();
    return true;
}

bool getEntropyfromDeviceDriver(int size, byte* pKey)
{
    return false;
}

bool getprogramNamefromDeviceDriver(int* pSize, const char* szName)
{
    // this is done elsewhere
    return true;
}

bool getpolicykeyfromDeviceDriver(u32* pkeyType, int* pSize, byte* pKey)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETPOLICYKEYFROMAPP, 0,
                               g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: sendtcBuf for encodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: gettcBuf for encodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEGETPOLICYKEYFROMOS(pkeyType, pSize, pKey, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: gettcBuf for decodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    PrintBytes("Policy key: ", pKey, *pSize);
#endif
    fprintf(g_logFile, "getpolicykeyfromDeviceDriverOS parent returns true\n");
    return true;
}

bool getOSMeasurementfromDeviceDriver(u32* phashType, int* pSize, byte* pHash)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "getOSMeasurementfromDeviceDriver\n");
#endif
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETOSHASHFROMAPP, 0,
                               g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: sendtcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: gettcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEGETOSHASHFROMTCSERVICE(phashType, pSize, pHash, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: gettcBuf for decodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST
    PrintBytes("OS hash: ", pHash, *pSize);
#endif
    fprintf(g_logFile, "getOSMeasurementfromDeviceDriver OS parent returns true\n");
    return true;
}

bool getHostedMeasurementfromDeviceDriver(int childproc, u32* phashType,
                                          int* pSize, byte* pHash)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver\n");
#endif
    // Does my pid have valid hash?
    size= encodeTCSERVICEGETPROGHASHFROMAPP(childproc, 1024, rgBuf);
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETPROGHASHFROMAPP,
                        0, g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: sendtcBuf for TCSERVICEGETPROGHASHFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: gettcBuf for TCSERVICEGETPROGHASHFROMAPP failed\n");
    }
    size= PARAMSIZE;
    if(!decodeTCSERVICEGETPROGHASHFROMSERVICE(phashType, pSize, pHash, 1024, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: cant decode os hash\n");
        return false;
    }

#ifdef TEST
    PrintBytes("getHostedMeasurementfromDeviceDriver prog hash: ", pHash, *pSize);
#endif
    return true;
}

bool startAppfromDeviceDriver(const char* szexecFile, int* ppid,
    int argc, char **argv)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

    size= encodeTCSERVICESTARTAPPFROMAPP(szexecFile, argc, argv, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "startProcessLinuxService: encodeTCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICESTARTAPPFROMAPP, 0, g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: sendtcBuf for TCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: gettcBuf for TCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICESTARTAPPFROMTCSERVICE(ppid, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: cant decode childproc\n");
        return false;
    }
#ifdef TEST
    fprintf(g_logFile, "startProcessLinuxService: Process created: %d by servicepid %d\n",
            *ppid, g_myPid);
#endif
    return true;
}

bool sealfromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "sealwithLinuxService(%d)\n", inSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICESEALFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "sealwithLinuxService: encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(getpid(), TCSERVICESEALFORFROMAPP, 0,
                               getpid(), size, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: sendtcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: gettcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICESEALFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: gettcBuf for decodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
#ifdef TCTEST1
    PrintBytes("To seal: ", inData, inSize);
    PrintBytes("Sealed :", outData, *poutSize);
#endif
    return true;
}

bool unsealfromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "unsealwithLinuxService(%d)\n", inSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICEUNSEALFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "unsealwithLinuxService: encodeTCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(getpid(), TCSERVICEUNSEALFORFROMAPP, 0, getpid(), size, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: sendtcBuf for TCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: gettcBuf for TCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEUNSEALFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: gettcBuf for decodeTCSERVICESEALFORFROMTCSERVICE failed\n");
        return false;
    }
#ifdef TCTEST1
    PrintBytes("To unseal: ", inData, inSize);
    PrintBytes("Unsealed : ", outData, *poutSize);
#endif
    return true;
}

bool quotefromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "quotewithLinuxService(%d, %d)\n", inSize, *poutSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICEATTESTFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "quotewithLinuxService: encodeTCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: sending %d\n", inSize);
    PrintBytes(" req buffer: ", inData, inSize);
    fflush(g_logFile);
#endif
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEATTESTFORFROMAPP, 0, procid, size, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: sendtcBuf for TCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: gettcBuf for TCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: rgBufsize is %d, status: %d\n",
            size, ustatus);
#endif
    if(!decodeTCSERVICEATTESTFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: gettcBuf for decodeTCSERVICEATTESTFORFROMTCSERVICEfailed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: outsize is %d\n", *poutSize);
    PrintBytes("To quote: ", inData, inSize);
    PrintBytes("Quoted : ", outData, *poutSize);
    fflush(g_logFile);
#endif
    return true;
}

// -------------------------------------------------------------------------

<commit_msg>turned on a debug in initLinuxservice<commit_after>//  File: linuxHostsupport.cpp
//      John Manferdelli
//  Description:  Support for Linux host as trusted OS
//
//  Copyright (c) 2012, John Manferdelli
//  Some contributions copyright (c) 2012, Intel Corporation
//
// Use, duplication and disclosure of this file and derived works of
// this file are subject to and licensed under the Apache License dated
// January, 2004, (the "License").  This License is contained in the
// top level directory originally provided with the CloudProxy Project.
// Your right to use or distribute this file, or derived works thereof,
// is subject to your being bound by those terms and your use indicates
// consent to those terms.
//
// If you distribute this file (or portions derived therefrom), you must
// include License in or with the file and, in the event you do not include
// the entire License in the file, the file must contain a reference
// to the location of the License.

#include "jlmTypes.h"
#include "logging.h"
#include "jlmcrypto.h"
#include "jlmUtility.h"
#include "modesandpadding.h"
#include "sha256.h"
#include "tao.h"
#include "bignum.h"
#include "mpFunctions.h"
#include "cryptoHelper.h"
#include "trustedKeyNego.h"
#include "tcIO.h"
#include "buffercoding.h"
#include "tcService.h"
#include <string.h>
#include <time.h>

// -------------------------------------------------------------------------

//
//   Service support from LINUX
//

// request channel to device driver
tcChannel   g_reqChannel;
int         g_myPid= -1;

bool initLinuxService(const char* name)
{
#ifdef TEST
    if(name!=NULL)
        fprintf(g_logFile, "initLinuxService started %s\n", name);
    else
        fprintf(g_logFile, "initLinuxService started no childname\n");
#endif

    g_myPid= getpid();
    if(!g_reqChannel.OpenBuf(TCDEVICEDRIVER, 0, name ,0)) {
        fprintf(g_logFile, "initLinuxService: OpenBuf returned false \n");
        return false;
    }

#ifdef TCTEST
    fprintf(g_logFile, "initLinuxService returns true\n");
#endif
    return true;
}

bool closeLinuxService()
{
    g_reqChannel.CloseBuf();
    return true;
}

bool getEntropyfromDeviceDriver(int size, byte* pKey)
{
    return false;
}

bool getprogramNamefromDeviceDriver(int* pSize, const char* szName)
{
    // this is done elsewhere
    return true;
}

bool getpolicykeyfromDeviceDriver(u32* pkeyType, int* pSize, byte* pKey)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETPOLICYKEYFROMAPP, 0,
                               g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: sendtcBuf for encodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: gettcBuf for encodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEGETPOLICYKEYFROMOS(pkeyType, pSize, pKey, rgBuf)) {
        fprintf(g_logFile, "getpolicykeyfromDeviceDriver: gettcBuf for decodeTCSERVICEPOLICYKEYFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    PrintBytes("Policy key: ", pKey, *pSize);
#endif
    fprintf(g_logFile, "getpolicykeyfromDeviceDriverOS parent returns true\n");
    return true;
}

bool getOSMeasurementfromDeviceDriver(u32* phashType, int* pSize, byte* pHash)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "getOSMeasurementfromDeviceDriver\n");
#endif
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETOSHASHFROMAPP, 0,
                               g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: sendtcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: gettcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEGETOSHASHFROMTCSERVICE(phashType, pSize, pHash, rgBuf)) {
        fprintf(g_logFile, "getOSMeasurementfromDeviceDriver: gettcBuf for decodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST
    PrintBytes("OS hash: ", pHash, *pSize);
#endif
    fprintf(g_logFile, "getOSMeasurementfromDeviceDriver OS parent returns true\n");
    return true;
}

bool getHostedMeasurementfromDeviceDriver(int childproc, u32* phashType,
                                          int* pSize, byte* pHash)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver\n");
#endif
    // Does my pid have valid hash?
    size= encodeTCSERVICEGETPROGHASHFROMAPP(childproc, 1024, rgBuf);
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEGETPROGHASHFROMAPP,
                        0, g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: sendtcBuf for TCSERVICEGETPROGHASHFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: gettcBuf for TCSERVICEGETPROGHASHFROMAPP failed\n");
    }
    size= PARAMSIZE;
    if(!decodeTCSERVICEGETPROGHASHFROMSERVICE(phashType, pSize, pHash, 1024, rgBuf)) {
        fprintf(g_logFile, "getHostedMeasurementfromDeviceDriver: cant decode os hash\n");
        return false;
    }

#ifdef TEST
    PrintBytes("getHostedMeasurementfromDeviceDriver prog hash: ", pHash, *pSize);
#endif
    return true;
}

bool startAppfromDeviceDriver(const char* szexecFile, int* ppid,
    int argc, char **argv)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= PARAMSIZE;
    byte        rgBuf[PARAMSIZE];

    size= encodeTCSERVICESTARTAPPFROMAPP(szexecFile, argc, argv, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "startProcessLinuxService: encodeTCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICESTARTAPPFROMAPP, 0, g_myPid, size, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: sendtcBuf for TCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: gettcBuf for TCSERVICESTARTAPPFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICESTARTAPPFROMTCSERVICE(ppid, rgBuf)) {
        fprintf(g_logFile, "startProcessLinuxService: cant decode childproc\n");
        return false;
    }
#ifdef TEST
    fprintf(g_logFile, "startProcessLinuxService: Process created: %d by servicepid %d\n",
            *ppid, g_myPid);
#endif
    return true;
}

bool sealfromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "sealwithLinuxService(%d)\n", inSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICESEALFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "sealwithLinuxService: encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(getpid(), TCSERVICESEALFORFROMAPP, 0,
                               getpid(), size, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: sendtcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: gettcBuf for encodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICESEALFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "sealwithLinuxService: gettcBuf for decodeTCSERVICESEALFORFROMAPP failed\n");
        return false;
    }
#ifdef TCTEST1
    PrintBytes("To seal: ", inData, inSize);
    PrintBytes("Sealed :", outData, *poutSize);
#endif
    return true;
}

bool unsealfromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "unsealwithLinuxService(%d)\n", inSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICEUNSEALFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "unsealwithLinuxService: encodeTCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    if(!g_reqChannel.sendtcBuf(getpid(), TCSERVICEUNSEALFORFROMAPP, 0, getpid(), size, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: sendtcBuf for TCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: gettcBuf for TCSERVICEUNSEALFORFROMAPP failed\n");
        return false;
    }
    if(!decodeTCSERVICEUNSEALFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "unsealwithLinuxService: gettcBuf for decodeTCSERVICESEALFORFROMTCSERVICE failed\n");
        return false;
    }
#ifdef TCTEST1
    PrintBytes("To unseal: ", inData, inSize);
    PrintBytes("Unsealed : ", outData, *poutSize);
#endif
    return true;
}

bool quotefromDeviceDriver(int inSize, byte* inData, int* poutSize, byte* outData)
{
    u32         ustatus;
    u32         ureq;
    int         procid;
    int         origprocid;
    int         size= 0;
    byte        rgBuf[PARAMSIZE];

#ifdef TEST
    fprintf(g_logFile, "quotewithLinuxService(%d, %d)\n", inSize, *poutSize);
#endif
    memset(outData, 0, *poutSize);
    size= encodeTCSERVICEATTESTFORFROMAPP(inSize, inData, PARAMSIZE, rgBuf);
    if(size<0) {
        fprintf(g_logFile, "quotewithLinuxService: encodeTCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: sending %d\n", inSize);
    PrintBytes(" req buffer: ", inData, inSize);
    fflush(g_logFile);
#endif
    if(!g_reqChannel.sendtcBuf(g_myPid, TCSERVICEATTESTFORFROMAPP, 0, procid, size, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: sendtcBuf for TCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
    size= PARAMSIZE;
    if(!g_reqChannel.gettcBuf(&procid, &ureq, &ustatus, &origprocid, &size, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: gettcBuf for TCSERVICEATTESTFORFROMAPP failed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: rgBufsize is %d, status: %d\n",
            size, ustatus);
#endif
    if(!decodeTCSERVICEATTESTFORFROMTCSERVICE(poutSize, outData, rgBuf)) {
        fprintf(g_logFile, "quotewithLinuxService: gettcBuf for decodeTCSERVICEATTESTFORFROMTCSERVICEfailed\n");
        return false;
    }
#ifdef TEST1
    fprintf(g_logFile, "quotewithLinuxService: outsize is %d\n", *poutSize);
    PrintBytes("To quote: ", inData, inSize);
    PrintBytes("Quoted : ", outData, *poutSize);
    fflush(g_logFile);
#endif
    return true;
}

// -------------------------------------------------------------------------

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: mediacontrol.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-07 19:34:56 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _AVMEDIA_MEDIACONTROL_HXX
#define _AVMEDIA_MEDIACONTROL_HXX

#include "mediaitem.hxx"

#include <vcl/timer.hxx>
#include <vcl/slider.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/image.hxx>

#define AVMEDIA_CONTROLOFFSET 6

class ListBox;

namespace avmedia
{

// ---------------------
// - MediaControlStyle -
// ---------------------

enum MediaControlStyle
{
    MEDIACONTROLSTYLE_SINGLELINE = 0,
    MEDIACONTROLSTYLE_MULTILINE = 1
};

// ----------------
// - MediaControl -
// ---------------

class MediaItem;

class MediaControl : public Control
{
public:

                        MediaControl( Window* pParent, MediaControlStyle eControlStyle );
                        ~MediaControl();

    const Size&         getMinSizePixel() const;

    void                setState( const MediaItem& rItem );
    void                getState( MediaItem& rItem ) const;

protected:

    virtual void        update() = 0;
    virtual void        execute( const MediaItem& rItem ) = 0;

    virtual void        Resize();

private:

    void                implUpdateToolboxes();
    void                implUpdateTimeSlider();
    void                implUpdateVolumeSlider();
    void                implUpdateTimeField( double fCurTime );
    Image               implGetImage( sal_Int32 nImageId ) const;

                        DECL_LINK( implTimeHdl, Slider* );
                        DECL_LINK( implTimeEndHdl, Slider* );
                        DECL_LINK( implVolumeHdl, Slider* );
                        DECL_LINK( implVolumeEndHdl, Slider* );
                        DECL_LINK( implSelectHdl, ToolBox* );
                        DECL_LINK( implZoomSelectHdl, ListBox* );
                        DECL_LINK( implTimeoutHdl, Timer* );

    ImageList           maImageList;
    Timer               maTimer;
    MediaItem           maItem;
    ToolBox             maPlayToolBox;
    Slider              maTimeSlider;;
    ToolBox             maMuteToolBox;
    Slider              maVolumeSlider;
    ToolBox             maZoomToolBox;
    ListBox*            mpZoomListBox;
    Edit                maTimeEdit;
    Size                maMinSize;
    MediaControlStyle   meControlStyle;
    bool                mbLocked;
};

}

#endif
<commit_msg>INTEGRATION: CWS warnings01 (1.3.24); FILE MERGED 2006/02/14 10:53:42 cl 1.3.24.2: removed extra ';' 2005/11/28 12:46:24 cl 1.3.24.1: warning free code fixes<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: mediacontrol.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-19 13:57:28 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

#ifndef _AVMEDIA_MEDIACONTROL_HXX
#define _AVMEDIA_MEDIACONTROL_HXX

#include "mediaitem.hxx"

#include <vcl/timer.hxx>
#include <vcl/slider.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/edit.hxx>
#include <vcl/image.hxx>

#define AVMEDIA_CONTROLOFFSET 6

class ListBox;

namespace avmedia
{

// ---------------------
// - MediaControlStyle -
// ---------------------

enum MediaControlStyle
{
    MEDIACONTROLSTYLE_SINGLELINE = 0,
    MEDIACONTROLSTYLE_MULTILINE = 1
};

// ----------------
// - MediaControl -
// ---------------

class MediaItem;

class MediaControl : public Control
{
public:

                        MediaControl( Window* pParent, MediaControlStyle eControlStyle );
    virtual             ~MediaControl();

    const Size&         getMinSizePixel() const;

    void                setState( const MediaItem& rItem );
    void                getState( MediaItem& rItem ) const;

protected:

    virtual void        update() = 0;
    virtual void        execute( const MediaItem& rItem ) = 0;

    virtual void        Resize();

private:

    void                implUpdateToolboxes();
    void                implUpdateTimeSlider();
    void                implUpdateVolumeSlider();
    void                implUpdateTimeField( double fCurTime );
    Image               implGetImage( sal_Int32 nImageId ) const;

                        DECL_LINK( implTimeHdl, Slider* );
                        DECL_LINK( implTimeEndHdl, Slider* );
                        DECL_LINK( implVolumeHdl, Slider* );
                        DECL_LINK( implVolumeEndHdl, Slider* );
                        DECL_LINK( implSelectHdl, ToolBox* );
                        DECL_LINK( implZoomSelectHdl, ListBox* );
                        DECL_LINK( implTimeoutHdl, Timer* );

    ImageList           maImageList;
    Timer               maTimer;
    MediaItem           maItem;
    ToolBox             maPlayToolBox;
    Slider              maTimeSlider;
    ToolBox             maMuteToolBox;
    Slider              maVolumeSlider;
    ToolBox             maZoomToolBox;
    ListBox*            mpZoomListBox;
    Edit                maTimeEdit;
    Size                maMinSize;
    MediaControlStyle   meControlStyle;
    bool                mbLocked;
};

}

#endif
<|endoftext|>